This is a very simple, but nice shell prompt.
PS1="\[\033[38;5;49m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;43m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]@\[$(tput sgr0)\]\[\033[38;5;39m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]:\$?:\\$\[$(tput sgr0)\]" |
This is what it looks like.
/home/robert/Desktop:mycomputer@mario:0:$ |
Another nice bash shell prompt.
PS1="-\t-- \u@\h [\w]\$ " |
It looks like this. Not as good, but simpler than the above example.
-12:01:11-- jason@unknown [~]$ |
Put this in your .bashrc to create more useful variables for use in your shell scripts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Setting a blinking block cursor for the console. echo -e '\033[?6c' # try to set DISPLAY smart (from Hans) :) # From a SUSE .bashrc file. # if test -z "$DISPLAY" -a "$TERM" = "xterm" -a -x /usr/bin/who ; then WHOAMI="`/usr/bin/who am i`" _DISPLAY="`expr "$WHOAMI" : '.*(\([^\.][^\.]*\).*)'`:0.0" if [ "${_DISPLAY}" != ":0:0.0" -a "${_DISPLAY}" != " :0.0" \ -a "${_DISPLAY}" != ":0.0" ]; then export DISPLAY="${_DISPLAY}"; fi unset WHOAMI _DISPLAY fi export EDITOR=mcedit export TIME_STYLE=+" %d-%m-%y %I:%M %P" # These two examples from bash-doc. export PAGER="/usr/bin/less" export VIEWER="mcedit" export LESS="-i -e -M -P%t?f%f :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-..." shopt -s checkwinsize [ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors" [ -e "$DIR_COLORS" ] || DIR_COLORS="" eval "`dircolors -b $DIR_COLORS`" |
Set some cool information in your terminal title bar. Put this in your .bashrc file.
1 2 3 4 5 6 7 | OSRELEASE=`uname -ir`; # Setting the value of the Xterm title. # Only if we are in X... if [ $DISPLAY ] ; then PROMPT_COMMAND='echo -ne "\033]0;${USER}@${OSRELEASE}: ${PWD}\007"' fi # Done... |
Determine which terminal we are using…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | case $TERM in # Testing for either xterm or rxvt or uxvt or uxterm... # etc. Works in a xterm on Open Solaris just fine.. *term | *xvt ) PS1='\n[ \e[041m\e[40m\e[37m\e[1m\u@${OSRELEASE}\e[41m\e[0m ]\n[ \e[033mJobs \j.\e[0m \ \e[30m\e[41m\e[1m\e[33mPWD: \w. \s \V.\e[0m ] [\e[4m \#-:\$ \e[0m]\n-> ' ;; esac fi # Outside of X we use this! if [ "$TERM" == "linux" ]; then PS1='\e[31m\e[40m\e[37m\e[1m\u@${OSRELEASE}.\e[0m\n \e[30m\e[41m\e[1m\e[33mPWD: \ \w.\e[0m \s.\n \V. \# \$> ' fi # Outside of xinit we use this! For Open Solaris. Which rules over FreeBSD Btw. if [ "$TERM" == "sun-color" ]; then PS1='\u@${OSRELEASE}.\n PWD: \w. \s.\n \V. \# \$> ' fi |
Determine which BASH version we are running, is it suitable for programmable completion?
if [ "${BASH_VERSION%.*}" \< "2.05" ]; then echo "You will need to upgrade to version 2.05 for programmable completion" return fi |
These samples will be very helpful in getting your BASH prompt looking very good, as well as helping out with customizing the title bar of your terminal and using different prompts for each terminal you use, whether it is xterm, rxvt or Gnome Terminal.