From 9390c4cf0634b47bd0ea20d070526f55978a03f9 Mon Sep 17 00:00:00 2001 From: Michael Turquette Date: Sun, 31 Aug 2014 19:50:34 -0700 Subject: [PATCH] themes: square: add short commit sha1 to prompt TODO: this solution is ugly. Find a better way. Signed-off-by: Michael Turquette --- themes/square/square.theme.bash | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/themes/square/square.theme.bash b/themes/square/square.theme.bash index 5beee8cf..fa42ab58 100644 --- a/themes/square/square.theme.bash +++ b/themes/square/square.theme.bash @@ -1,7 +1,24 @@ #!/usr/bin/env bash +function git_short_sha() { + SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$SHA" +} + prompt() { - PS1="${green}\w${reset_color} $(__git_ps1 [${red}%s${reset_color}])$ " + local sha="${yellow}$(git_short_sha)${reset_color}" + local branch="$(__git_ps1 ${red}%s${reset_color})" + # failed attempt to merge the two above + #local branch="$(__git_ps1 ${red}%s${reset_color} ${sha})" + + # the original + #PS1="${green}\w${reset_color} $(__git_ps1 [${red}%s${reset_color}])$ " + + # with persistent brackets + #PS1="${green}\w${reset_color} [${branch} ${sha}]$ " + # without any brackets + PS1="${green}\w${reset_color} ${branch} ${sha}$ " + # failed attempt at conditional brackets + #PS1="${green}\w${reset_color} ${branch}$ " } PROMPT_COMMAND=prompt