Enhance bash prompt PS1
From FVue
Problem
I think I can cram more information in the bash prompt compared to what it looks now.
Solution
Journal
20061009
# My prompt. # Color references: Black 0;30 Dark Gray 1;30 # Blue 0;34 Light Blue 1;34 # Green 0;32 Light Green 1;32 # Cyan 0;36 Light Cyan 1;36 # Red 0;31 Light Red 1;31 # Purple 0;35 Light Purple 1;35 # Brown 0;33 Yellow 1;33 # Light Gray 0;37 White 1;37 # See also: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/ export PS1=$'\[\e[0;34m\]\!\[\e[0m\]\[\e[1;32m\]$(stoppedjobs)\[\e[0m\]:\u@\h:\w> '
996%1:freddy@linux:~>
Drawbacks of the prompt above are that:
- used with
HISTCONTROL=erasedups
, the on-screen history numbers are not correct since 'erasedups' may remove in-between history entries. UseHISTCONTROL=ignoredups
instead.
20081121
Added color reset (\[\e[m\]) at end of prompt to prevent cursor mispositioning:
# My prompt. # Color references: Black 0;30 Dark Gray 1;30 # Blue 0;34 Light Blue 1;34 # Green 0;32 Light Green 1;32 # Cyan 0;36 Light Cyan 1;36 # Red 0;31 Light Red 1;31 # Purple 0;35 Light Purple 1;35 # Brown 0;33 Yellow 1;33 # Light Gray 0;37 White 1;37 # See also: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/ export PS1=$'\[\e[0;34m\]\!\[\e[0m\]\[\e[1;32m\]$(stoppedjobs)\[\e[0m\]:\u@\h:\w> \[\e[m\]'
See also: http://groups.google.com/group/gnu.bash.bug/browse_thread/thread/9da7e81b060d77d4
Advertisement