Last active
December 11, 2015 23:18
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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