Created
August 15, 2013 19:03
-
-
Save papaben/6243750 to your computer and use it in GitHub Desktop.
Bash PS1
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
# Red if last command failed | |
function __last_cmd_code_ps1() { | |
local red='\033[00;31m' # red | |
if [ $1 -ne 0 ]; then | |
echo -e "${red}*!!**${1}**!!*${red}" | |
return | |
fi | |
} | |
function prompt() { | |
local nc='\033[0m' # no color | |
local green='\033[00;32m' | |
local purple='\033[01;35m' | |
local cyan='\033[00;36m' | |
# User@hostname date time directory\nCommand Number $ - me, # - root | |
# __git_ps1 - show current git branch; http://blog.jasonmeridth.com/2010/05/22/git-ps1.html | |
local ps1=$(echo $cyan'{{'$green'\u@$SHORTNAME \D{%Y-%m-%d} \t '$cyan'\w'$purple'$(__git_ps1 " (%s)" 2>/dev/null)'$cyan'}}') | |
PS1=$(echo '$(__last_cmd_code_ps1 $?)'"$ps1""$nc"'\n[\!]\$ '); | |
} | |
prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment