Skip to content

Instantly share code, notes, and snippets.

@socantre
Last active December 11, 2015 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save socantre/4675288 to your computer and use it in GitHub Desktop.
Save socantre/4675288 to your computer and use it in GitHub Desktop.
bash prompt:{exit code of previous command} [hostname username pwd] date and time (right justified)
# vi input mode (bash)
set -o vi
# Mac OS X 10.10.5
export PS1='\n$(cat <<< $? > ~/.exit_code)$(/bin/date "+%l:%M:%S %p %z %A %d %B %Y" | awk "{ printf \"%*s\", $(tput cols),\$0}")\r{$(cat ~/.exit_code)} [\h \u \w] \n$ '
# Windows, mintty
export PS1='\[\e[31;40m\]\n{$?} [\h \u \w]\[\e[0m\]\[\e[31;40m\]\n`/bin/date --utc --iso-8601=seconds`\[\e[0m\]\n$ '
# Time with preexec/precmd
# https://github.com/rcaloras/bash-preexec.git
source ~/Dropbox/bash-preexec/bash-preexec.sh
export PS1='\[\e[31;40m\]{$?} [\h \u \w]\[\e[0m\]\n`__git_ps1 "\e[31;40mbranch: (%s)\e[0m\n\e[0m"`\[\e[31;40m\]:>\[\e[0m\] '
function precmd() { printf '\n\e[31;40m%s\e[0m\n' `/bin/date --utc --iso-8601=seconds`; }
function preexec() { printf '\e[31;40m%s\e[0m\n' `/bin/date --utc --iso-8601=seconds`; }
# OS X 10.10 version of date
# /bin/date -u "+%Y-%m-%dT%H:%M:%S%z"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment