Bash CLI Hacks

  1. Shows PLUS or MINUS depending on command completion

  2. Open /home/user/.bashrc with a text editor,

  • +++ = command worked, --- = command did not work

  • Obvisously you can change the symbols to anything you like.

  1. Add below to your .bashrc
PS1="\`if [ \$? = 0 ]; then echo \[\e[33m\]+++\[\e[0m\]; else echo \[\e[31m\]---\[\e[0m\]; fi\`[\u@\h:\w]\\$"

  1. Prompt changes color when depending on completion, It also shows present working directory, pwd, and hostname.

  2. Open /home/user/.bashrc with a text editor,

  3. Add below to your .bashrc

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 " "` > 18 ]]; then echo "\\W"; else echo "\\w"; fi\`]\$\[\033[0m\] "; echo -ne "\033]0;`hostname -s`:`pwd`\007"'

See also