PS1='...:\[$(((\j > 0))&&{ tput setaf 1;tput bold;})\]\j\[$(tput sgr0)\]...'
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.
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 )\$ '
for synology without the \[ and \]
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;31mrc:$RET\e[00m "; fi )\$ '
(to make it permanent put this in ~/.bash_profile or ~/.bashrc)
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) |
device | location |
---|---|
Synology | /etc/profile |
CentOS | /etc/profile.d/localbashrc.sh |
Just end with the color you want to give your command and add:
trap 'echo -ne "\e[0m"' DEBUG
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. |
to my prompt that would be red and bold if its greater than zero and regular and white if it was zero. If this "if" behavior is not possible, then I could just have it always white and regular text. Could anyone help me out with this? Below is the output of my PS1 variable.
PS1='...:\[$(((\j > 0))&&{ tput setaf 1;tput bold;})\]\j\[$(tput sgr0)\]...'
FancyX='\342\234\227' Checkmark='\342\234\223'
but then you need to use unicode
On Synology probably from version 5 the \[ and \] should not be used, is't automatically subtracted from the visible character counter.