Dynamic BASH Prompt


/ Published in: Bash
Save to your folder(s)

A very dynamic and flexible bash prompt. Personally I find this to have everything needed. It shows exit status, shortens itself for long directories, and shows bash history for easy referencing.

Hopefully it doesn't get messed up.


Copy this code and paste it in your HTML
  1. export MAX_PATH_LENGTH=25
  2. export PROMPT_COMMAND='PS1="\[\033[0;33m\][\!]\`if [[ \$? = "0" ]]; then echo "\\[\\033[32m\\]"; else echo "\\[\\033[31m\\]"; fi\`[\u.\h: \`if [[ `pwd|wc -c|tr -d " "` > $MAX_PATH_LENGTH ]]; then echo "\\W"; else echo "\\w"; fi\`]\$\[\033[0m\] "; echo -ne "\033]0;`hostname -s`:`pwd`\007"'

URL: http://blog.ubrio.us/osx/best-bash-prompt/

Report this snippet


Comments


You need to login to view comments.