Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If a word begins with an unquoted tilde character (`~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the tilde are treated as a possible login name. If this login name is the null string, the tilde is replaced with the value of the shell parameter HOME. If HOME is unset, the home directory of the user executing the shell is substituted instead. Otherwise, the tilde-prefix is replaced with the home directory associated with the specified login name.
If the tilde-prefix is a `~+', the value of the shell variable PWD replaces the tilde-prefix. If the tilde-prefix is a `~-', the value of the shell variable OLDPWD, if it is set, is substituted. If the characters following the tilde in the tilde-prefix consist of a number N, optionally prefixed by a `+' or a `-', the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the dirs builtin invoked with the tilde-prefix as an argument. If the characters following the tilde in the tilde-prefix consist of a number without a leading `+' or `-', `+' is assumed.
If the login name is invalid, or the tilde expansion fails, the word is unchanged.
Each variable assignment is checked for unquoted tilde-prefixes immediately following a : or the first =. In these cases, tilde expansion is also performed. Consequently, one may use file names with tildes in assignments to PATH, MAILPATH, and CDPATH, and the shell assigns the expanded value.
from bash manpage, also
When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command. Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:
an ASCII bell character (07)
the date in "Weekday Month Date" format (e.g., "Tue May 26")
the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
an ASCII escape character (033)
the hostname up to the first `.'
the number of jobs currently managed by the shell
the basename of the shell's terminal device name
the name of the shell, the basename of $0 (the portion following the final slash)
the current time in 24-hour HH:MM:SS format
the current time in 12-hour HH:MM:SS format
the current time in 12-hour am/pm format
the current time in 24-hour HH:MM format
the username of the current user
the version of bash (e.g., 2.00)
the release of bash, version + patch level (e.g., 2.00.0)
the current working directory, with $HOME abbreviated with a tilde
the basename of the current working directory, with $HOME abbreviated with a tilde
the history number of this command
the command number of this command
if the effective UID is 0, a #, otherwise a $
the character corresponding to the octal number nnn
begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
end a sequence of non-printing characters
hope these answer your question, and "man" is your true friend.