[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Configuration

Yafc will parse a system-wide configuration file, `/etc/yafcrc', first. Then, personal settings are read from `~/.yafc/yafcrc' (overriding the global ones). If none of those files exists, internal defaults will be used.

The `--dump-rc' option of Yafc can be used to dump the default configuration file to standard output. You can create your own config file with the command yafc --dump-rc > ~/.yafc/yafcrc. You can customize it with your favourite editor, it should be quite self-explaining if you read the comments.

Yafc also looks for `~/.netrc', and reads autologin information from that file. This file is also used by the standard ftp client.

Yafc uses the Readline library to read commands from the terminal, and Readline can be configured via the `~/.inputrc' file. In this file you can put keybindings and Readline-oriented options. You can use $yafc for conditional parsing of the `~/.inputrc' file. A sample inputrc file is included in the distribution.

4.1 Keywords  Configuration keywords used
4.2 Prompt codes  Special codes in the prompts
4.3 Transfer codes  Special codes in the transfer strings
4.4 Aliases  Writing aliases
4.5 Colors  Using colors


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Keywords

The configuration file consists of keywords with an argument, separated with a space. There are three types of arguments: strings, booleans and integers. Strings must be enclosed in quotes if they contains spaces. Boolean arguments can be written as 0/1, true/false or on/off. The keywords are case insensitive.

These are the supported keywords:

anon_password
type: string

This is the password used for anonymous logins. It should be your email address.

autologin
type: boolean

Setting this to true will cause yafc to attempt to login automatically. Information for doing this is specified by See section 5. Bookmarks.

autoreconnect
type: boolean

If this option is true, yafc will try to reconnect the currently open connection if it has timed out. The directory cache is retained after a successful reconnect.

quit_on_eof
type: boolean

Quits yafc on end-of-file (usually Ctrl-D).

read_netrc
type: boolean

Read additional autologin entries from `~/.netrc'. 5. Bookmarks.

use_passive_mode
type: boolean

If true, use passive mode data connections. You might have to do this if you are behind a proxy.

reverse_dns
type: boolean

If this option is true, IP addresses will be reverse looked up in the DNS for a hostname, which can be slow. Set to false to skip this.

verbose
type: boolean

Show all replies received from remote host.

debug
type: boolean

Show exactly what is going on. Prints all FTP commands sent to remote host and all replies received, including response code.

trace
type: string

Create trace files in `~/.yafc/trace/trace.<pid>'.

ssh_program
type: string

Path to local ssh program which will be used in SSH2 connections. Note that only SSH version 2 is supported.

sftp_server_program
type: string

Path to remote sftp-server program. Leave commented to use the sftp subsystem. See also 3.1.32 open.

inhibit_startup_syst
type: boolean

Set to true to skip query of remote system on connect.

use_env_string
type: boolean

Alter the environment strings to reflect what Yafc is doing. This information can be seen with the shell command ps.

remote_completion
type: boolean

Use tab to complete remote files. Yeahh.

auto_bookmark
type: yes/no/ask

If set to yes, Yafc automatically creates a bookmarks for the site when the connection is closed. Setting this to ask, makes Yafc to ask if to create the bookmark.

The bookmark is given an appropriate aliases name.

auto_bookmark_save_password
type: boolean

If set to yes, Yafc don't ask whether to save passwords in the bookmarks file. Anonymous password, though, are always saved.

Passwords in the bookmarks file are stored either as clear text or base64-encoded. Be sure the file is not world readable (chmod 0600 bookmarks.)

auto_bookmark_silent
type: boolean

If set to true, Yafc won't say anything about automatically created bookmarks.

default_type
type: string

Specifies the default type used for file transfers, either binary or ascii. Setting this to ascii can mess up binary files (ascii mode rewrites the end-of-line characters).

default_mechanism
type: string

This option specifies which security mechanisms to try, in given order. It is a colon-separated string, supported values are "krb4", "krb5" and "none". Example: default_mechanism "krb4:krb5"

ascii_transfer_mask
type: string

Filenames matching any of these filemasks are always transferred in ascii mode, regardless of the value of the default_type keyword. This can be overridden with the `--type' option to get/put.

Masks are separated by colons (eg. *.ext1:*.ext2:filename*) and are case sensitive.

Preferrably used with default_type set to binary.

beep_after_long_command
type: boolean

Beep after a long command is finished. Use long_command_time to specify how long a `long' command is.

long_command_time
type: integer

Number of seconds for command to become `long'

command_timeout
type: integer

How long (in seconds) before aborting a command without response.

connection_timeout
type: integer

How long (in seconds) before aborting a connection without response.

connect_attempts
type: integer

Number of times to try to re-connect if login failed (due to busy server.) Use the value -1 for unlimited number of tries, and 0 to disable this feature.

connect_wait_time
type: integer

Number of seconds to wait between connection attempts.

use_history
type: boolean

Save and load history lines in `~/.yafc/history'. This is a no-op if not compiled with Readline.

history_max
type: integer

Max number of history lines to save in the history file. This is a no-op if not compiled with Readline.

startup_local_directory
type: string

Yafc will change to this (local) directory upon startup.

nohup_mailaddress
type: string

If set, Yafc sends mail to this address when nohup transfers are finished. 3.2 Nohup transfers.

sendmail_path
type: string

Complete path to sendmail used by `nohup_mailaddress' above.

prompt1
type: string

This prompt is printed when no connection is established.

See 4.2 Prompt codes.

You can put escape codes here, for example if you want a colored prompt "%{\e[01;31m%}ftp%{\e[0m%}" will be "ftp" in red, if your terminal supports ISO 6429 (ANSI) color codes. 4.5 Colors.

prompt2
type: string

connected but not logged in.

prompt3
type: string

connected and logged in

transfer_begin_string
type: string

This string is printed before the actual transfer begins.

These strings are printed with the `--verbose' option to get/put.

4.3 Transfer codes for special character codes that can be used in this string to show dynamic information.

transfer_string
type: string

This string is printed (approx.) every second or so during the transfer with a trailing carriage return.

4.3 Transfer codes for special character codes that can be used in this string to show dynamic information.

transfer_end_string
type: string

This string is printed when the transfer is finished.

4.3 Transfer codes for special character codes that can be used in this string to show dynamic information.

transfer_xterm_string
type: string

This string is printed at the same time `transfer_string' is printed, if the current $TERM variable is defined in `xterm_title_terms'. This string can be used to reflect dynamic information about the current transfer in the title bar of an Xterm.

4.3 Transfer codes for special character codes that can be used in this string to show dynamic information.

tilde
type: boolean

Display ~ instead of full home directory path for various commands.

xterm_title1
type: string

Xterm window titles

same codes as for the prompts, see See section 4.2 Prompt codes.

This is an excerpt from the Xterm-title mini-HOWTO:

Many people find it useful to set the title of a terminal to reflect dynamic information, such as the name of the host the user is logged into, the current working directory, etc.

This may be done by using XTerm escape sequences. The following sequences are useful in this respect:

ESC]0;_string_BEL
Set icon name and window title to _string_

ESC]1;_string_BEL
Set icon name to _string_

ESC]2;_string_BEL
Set window title to _string_

where ESC is the _escape_ character (\033), and BEL is the _bell_ character (\007).

_Note_: these sequences apply to most xterm derivatives, such as nxterm, color-xterm and rxvt. Other terminal types often use different escapes; see the appendix for examples. For the full list of xterm escape sequences see the file ctlseq2.txt, which comes with the xterm distribution, or xterm.seq, which comes with the rxvt distribution.

These escapes really need to be applied every time the prompt changes. This way the string is updated with every command you issue and can keep track of information such as current working directory, username, hostname, etc.

Example: xterm_title1 "\e]0;Yafc\x07" sets the xterm window title and icon name to Yafc.

xterm_title2
type: string

Example: xterm_title1 "\e]0:Yafc - %h\x07" sets the xterm window title and icon name to Yafc - hostname.

xterm_title3
type: string

Example: xterm_title1 "\e]0;Yafc - %u@%h:%~\x07" sets the xterm window title and icon name to Yafc - user@hostname:directory.

xterm_title_terms
type: string

List of $TERM's, separated with spaces, which can handle xterm escape sequences.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Prompt codes

These codes can be used in the prompts, 4.1 Keywords, to reflect dynamic information. For all codes, there may be an optional minimum field width. This is an integer between the '%' and the code character.

`%u'
username

`%h'
remote host name (as passed to open)

`%H'
%h up to the first '.'

`%m'
remote machine name (as returned by gethostbyname)

`%M'
%m up to the first '.'

`%n'
remote IP number

`%w'
current remote working directory

`%W'
basename of %w

`%~'
as %w but home directory is replaced with ~

`%l'
current local working directory

`%L'
basename of %l

`%c'
Total number of connections open

`%C'
The number of the currently active connection

`%%'
a percent sign

`%#'
a '#' if (local) user is root, else '$'

`%{'
begin sequence of non-printing chars, ie escape codes

`%}'
end sequence of non-printing chars, ie escape codes

`\e'
an escape character (hex 0x1B)

`\n'
a newline

`\t'
a tab character

`\r'
a carriage return

`\x##'
character 0x## (hex)

Example:

 
prompt3 "(%C) %{\e[1%}myafc%{\e[0m%} %u@%h:%42~> "


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 Transfer codes

These codes can be used in the transfer strings. For all codes, there may be an optional minimum field width. This is an integer between the '%' and the code character. For example will %17v be expanded to a visual progress bar with length 17. If the field width if negative (start with a minus), the string is left-justified, so using %-20S will show the total size, padded with spaces to 20 characters.

`%r'
source filename

`%R'
source filename w/path

`%l'
target filename

`%L'
target filename w/path

`%s'
size transferred so far

`%S'
total size (if available)

`%e'
ETA (time left)

`%p'
percent transferred so far

`%%'
percent sign

`%b'
transfer rate (Bps)

`%B'
transfer rate (Bps) or "stalled" if stalled

`%t'
time elapsed

`%v'
visual progress bar

Example:

 
transfer_string "%5p%% [%{\e[32m%}%25v%{\e[0m%}] %s/%S ETA %{\e[32m%}%e%{\e[0m%} %B"


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 Aliases

Just like in the shell, you can create aliases for commands you use often, with options you like.

Aliases can be defined in the configuration file or directly on the command line. Aliases defined on the command line are only valid in the current session. 3.1.3 alias.

The best way to explain aliases, I think, is to look at some examples:

4.4.1 Alias examples  examples on aliases


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.1 Alias examples

`alias ls "ls -F --color"'
Override the command ls to be expanded to ls -F --color. Any arguments given to the new ls alias will be appended.

`alias ll "ls -l"'
ll will be expanded to ls -l, regardless if there is an alias for plain ls like the one above. Aliases can't be nested.

`alias ls list'
Override the command ls to be expanded to the command list. This is fine, but will generate a warning; warning: alias 'ls' shadows a command with the same name, because the original command ls is lost and can't be referenced (except through another alias.)

`alias pls "ls %1 | less"'
Create a new command pls, which lists the contents of a directory and pages it through the pager less. The %1 keyword is replaced with the first argument to pls, any other arguments will be appended at the end (to the local less command.)

`alias pls "ls %* | $PAGER"'
Create a new command pls, which lists the contents of a directory and pages it through your favourite pager. Any arguments given to pls will be inserted between ls and the pipe because of the %* keyword. Using $PAGER is fine, it is expanded by the ordinary shell.

`alias rels "cache --touch %*; ls -F --color %*"'
Create a new command rels, which flushes the directories from the cache before listing them. Two %* sequences are needed to insert the arguments at both places.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5 Colors

Escape codes can be used to display colors in the transfer strings and the prompts. All escape codes must be surrounded by %{ and %} pairs for readline to correctly wrap long lines.

The built-in command ls has an option `--color'. You must set the environment variable LS_COLORS (or LS_COLOURS) for this to work. See manpage for GNU ls(1) and See Info file `fileutils', node `dircolors invocation', for information how to do this. If you don't set LS_COLO[U]RS, you can still use the `--color' option, since Yafc provides some default settings.

4.5.1 ANSI attribute codes  Escape codes for attributes


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5.1 ANSI attribute codes

An ANSI escape sequence has the format ESC[X;Ym, where ESC is the escape character (octal 033). X and, optionally, Y, is one of the following escape codes:

For example, the sequence ESC[1;32myafc rulesESC[0m will be the string yafc rules in bright green, after which the attribute is restored to normal.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Martin Hedenfalk on July, 27 2001 using texi2html