From 312e8266c90a3e4c41a15e1a80f321d39b5598c6 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 8 Apr 2014 11:22:09 -0700 Subject: [PATCH] Small fixes for bash prompt. --- dotfiles/lib/bash/prompt.sh | 38 ++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/dotfiles/lib/bash/prompt.sh b/dotfiles/lib/bash/prompt.sh index 2a71138f..f075a5b0 100644 --- a/dotfiles/lib/bash/prompt.sh +++ b/dotfiles/lib/bash/prompt.sh @@ -1,15 +1,47 @@ +# Regular Colors +Black='\e[0;30m' # Black +Red='\e[0;31m' # Red +Green='\e[0;32m' # Green +Yellow='\e[0;33m' # Yellow +Blue='\e[0;34m' # Blue +Purple='\e[0;35m' # Purple +Cyan='\e[0;36m' # Cyan +White='\e[0;37m' # White + function current_directory() { local PWD=$(pwd) echo "${PWD/#$HOME/~}" } -function git_prompt_info () { +function current_directory() { + local PWD=$(pwd) + echo "${PWD/#$HOME/~}" +} + +function git_prompt_info() { if test -z $(parse_git_branch); then echo "" else - echo "on $(parse_git_branch)" + echo " on $(parse_git_branch)$(git_status_character)" fi } -PS1='%u at $(hostname -s) in $(current_directory) $(git_prompt_info) $(colored_sandbox_string) ' +function git_status_character() { + if git_is_dirty; + then + echo "✘" + else + echo "✔" + fi +} + +function sandbox_prompt() { + if [ ! -z $(sandbox_prompt_info) ]; + then + echo " with $(colored_sandbox_string)" + fi +} + +PS1="╭─% ${Green}\u ${White}at ${Blue}\h ${White}in \$(current_directory)\$(git_prompt_info)\$(sandbox_prompt) +╰─± "