Skip to content

Instantly share code, notes, and snippets.

@MTN-RowinAndruscavage
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save MTN-RowinAndruscavage/58e65c1030034d46f9fc to your computer and use it in GitHub Desktop.

Select an option

Save MTN-RowinAndruscavage/58e65c1030034d46f9fc to your computer and use it in GitHub Desktop.
BASH prompt
PS1=$'\[\033[01;36;44m\]# $( EC=$?; [ $EC -eq 0 ] && echo -n "\[\033[01;32;44m\]Exit:$EC" || echo -n "\[\033[00;31;44m\]Exit:$EC" ) \
\[\033[00;37;44m\]$(date +%Y-%m-%d\ %H:%M:%S) \[\033[01;34;49m\] \
\[\033[01;30;49m\][\[\033[00;35;49m\]\u\[\033[01;30;49m\]@\[\033[01;34;49m\]\h\[\033[01;30;49m\]:\
\[\033[00;33;49m\]\w\[\033[00;36;49m\]\[\033[01;30;49m\]]\[\033[01;34;49m\]\n\
\[\033[01;36;49m\]\$\[\033[01;30;49m\](: !\! )\[\033[00;00;00m\] '
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;\W\a\]$PS1"
;;
*)
;;
esac
## bash history tweaks from http://blog.sanctum.geek.nz/better-bash-history/
HISTFILESIZE=1000000
HISTSIZE=1000000
HISTCONTROL=ignoreboth
HISTIGNORE='ls:bg:fg:history'
HISTTIMEFORMAT=$'\033[01;30;49m%F %T\033[00;00;00m '
shopt -s histappend
@MTN-RowinAndruscavage
Copy link
Author

Sample: http://imgur.com/zgWA4BG

Nothing fancy, just addresses a few things that annoy me about standard prompts:

  • Displays exit code of last command in green or red
  • timestamp of when last command completed
  • shows user@host:path for easy copy / paste into rsync / scp commands
  • shows command number for !501 completion
  • comment formatting # and $(: ... ) allow for easy copy-n-paste of shell sessions into documentation, so others can copy and paste to repeat your commands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment