Info
- PROMPT_COMMAND and is execed right in front of the PS1
- PS1 specifies the format of your regular prompt that appears to the left of every new command you type
PS2
defines the continuation prompt: It appears when you enter a line ending with a backslash to continue input on the next line.
A real good page about all kinds of options.
THE Prompt
export PS1='\[\e[1;33m\]\u@\h\[\e[0m\]:\[\e[1;34m\]\W\[\e[0m\] \e]2;\u@\H:\w - susp:\j\a$( RET=$?; if [ $RET != 0 ] ; then echo "\[\e[1;31m\]rc:$RET\[\e[00m\] "; fi )\$ '
...
Code | Explained |
---|---|
'\[\e[1;33m\]' | Bold Yellow text (0;33 would be dark yellow) |
'\u@\h' | \u for username, fixed '@', \h for first part of hostname |
'\[\e[0m\]' | reset foreground, background, and boldness settings to their default values |
':' | fixed ':' |
'\[\e[01;34m\]' | Bold Blue text |
\W | The "basename of the current netowkr directory (drobbins from /home/frobbins) |
| |
'\[\e[0m\]' | |
' \$ ' | If you are not root, inserts a "$"; if you are root, you get a "#" |
'\e]2;\u@\H:$( pwd )- susp: \j\a' | text within \e2; and \a will be put into the titlebar of the X terminal: Would like to use $( pwd ) for current working dir since \w shows ~, but then RET doesn't work on syno fixed '- susp: ', \j for number of suspended processes |
| show (red) return code if not 0 |
| execute bash command (like pwd) |
The location
device | location |
---|---|
Synology | /etc/profile |
CentOS | /etc/profile.d/localbashrc.sh |
Collored command input
Just end with the color you want to give your command and add:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
trap 'echo -ne "\e[0m"' DEBUG |
Extra info
ANSI Escape sequences
See: Good complete link
Sequence | Description |
---|---|
\a | The ASCII bell character (you can also type \007) |
\d | Date in "Wed Sep 06" format |
\e | ASCII escape character (you can also type \033) |
\h | First part of hostname (such as "mybox") |
\H | Full hostname (such as "mybox.mydomain.com") |
\j | The number of processes you've suspended in this shell by hitting ^Z |
\l | The name of the shell's terminal device (such as "ttyp4") |
\n | Newline |
\r | Carriage return |
\s | The name of the shell executable (such as "bash") |
\t | Time in 24-hour format (such as "23:01:01") |
\T | Time in 12-hour format (such as "11:01:01") |
\@ | Time in 12-hour format with am/pm |
\u | Your username |
\v | Version of bash (such as 2.04) |
\V | Bash version, including patchlevel |
\w | Current working directory (such as "/home/drobbins") |
\W | The "basename" of the current working directory (such as "drobbins") |
\! | Current command's position in the history buffer |
\# | Command number (this will count up at each prompt, as long as you type something) |
\$ | If you are not root, inserts a "$"; if you are root, you get a "#" |
\xxx | Inserts an ASCII character based on three-digit number xxx (replace unused digits with zeros, such as "\007") |
\\ | A backslash |
\[ | This sequence should appear before a sequence of characters that don't move the cursor (like color escape sequences). This allows bash to calculate word wrapping correctly. |
\] | This sequence should appear after a sequence of non-printing characters. |
...
On Synology probably from version 5 the \[ and \] should not be used, is't automatically subtracted from the visible character counter.