From 7785f93586005a16cc67d4c3aae4dd19f3b0af8a Mon Sep 17 00:00:00 2001 From: switch87 Date: Mon, 13 Mar 2017 20:22:10 +0100 Subject: [PATCH 1/3] added own custom theme --- themes/Minimal_Switch.bgptheme | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 themes/Minimal_Switch.bgptheme diff --git a/themes/Minimal_Switch.bgptheme b/themes/Minimal_Switch.bgptheme new file mode 100644 index 0000000..65491f7 --- /dev/null +++ b/themes/Minimal_Switch.bgptheme @@ -0,0 +1,61 @@ +############################################################################## +# Changes the prompt to a Debian-style one that truncates pwd to a max length +# depending on the terminal column width. Also uses the prompt_callback +# function of bash-git-prompt to set the window title to almost the same +# Debian-style. This version has been tweaked for Ubuntu standard terminal +# fonts. +# +# The prompt will use a Debian-style on the form +# +# relative-path-from-git-toplevel-dir bash-git-prompt-info +# HH:MM:SS ▶ +# +# The window title will have the form +# relative-path-from-git-toplevel-dir +# +# Example usage: +# if [ -f ~/.bash-git-prompt/gitprompt.sh ]; then +# GIT_PROMPT_THEME=Minimal +# source ~/.bash-git-prompt/gitprompt.sh +# fi +# +# Imbibinebe [https://github.com/imbibinebe] +############################################################################## +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Minimal" + + #Overrides the prompt_callback function used by bash-git-prompt + function prompt_callback { + GIT_CONTAINER_FOLDER_FULLPATH=$(git rev-parse --show-toplevel 2> /dev/null) + GIT_CONTAINER_FOLDER=$(basename $GIT_CONTAINER_FOLDER_FULLPATH 2> /dev/null) + CURRENT_FULLPATH=$(pwd) + local PS1=$GIT_CONTAINER_FOLDER${CURRENT_FULLPATH#$GIT_CONTAINER_FOLDER_FULLPATH} + gp_set_window_title "$PS1" + echo -n "${BoldYellow}${PS1}${ResetColor}" + } + + Time12a="\$(date +%H:%M:%S)" + GIT_PROMPT_BRANCH="${BoldMagenta}" # the git branch that is active in the current directory + GIT_PROMPT_PREFIX="" # start of the git info string + GIT_PROMPT_SUFFIX="" # the end of the git info string + GIT_PROMPT_SEPARATOR="" # separates each item + GIT_PROMPT_STAGED=" ${Green}●" # the number of staged files/directories + GIT_PROMPT_CONFLICTS=" ${BoldRed}✖" # the number of files in conflict + GIT_PROMPT_CHANGED=" ${BoldBlue}✚" # the number of changed files + + # GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind + GIT_PROMPT_UNTRACKED=" ${Cyan}…" # the number of untracked files/dirs + GIT_PROMPT_STASHED=" ${BoldCyan}⚑" # the number of stashed files/dir + GIT_PROMPT_CLEAN=" ${BoldGreen}✔" # a colored flag indicating a "clean" repo + + local gp_end="_LAST_COMMAND_INDICATOR_\n${BoldBlack}${Time12a} ${BoldGreen}$(whoami)@$(hostname)${ResetColor}" + + GIT_PROMPT_START_USER="" + GIT_PROMPT_END_USER="${gp_end} ▶ " + GIT_PROMPT_END_ROOT="${gp_end} /!!!\ " + + GIT_PROMPT_COMMAND_OK="${Green} ✔ " # indicator if the last command returned with an exit code of 0 + GIT_PROMPT_COMMAND_FAIL="${BoldRed} ✘-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0 +} + +reload_git_prompt_colors "Minimal" From 7e695b36b995676517d5d7f5faf546971025be03 Mon Sep 17 00:00:00 2001 From: switch87 Date: Mon, 13 Mar 2017 20:52:01 +0100 Subject: [PATCH 2/3] renamed theme and added root-color --- ...Switch.bgptheme => Minimal_UserHost.bgptheme} | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) rename themes/{Minimal_Switch.bgptheme => Minimal_UserHost.bgptheme} (87%) diff --git a/themes/Minimal_Switch.bgptheme b/themes/Minimal_UserHost.bgptheme similarity index 87% rename from themes/Minimal_Switch.bgptheme rename to themes/Minimal_UserHost.bgptheme index 65491f7..f95b97b 100644 --- a/themes/Minimal_Switch.bgptheme +++ b/themes/Minimal_UserHost.bgptheme @@ -8,18 +8,20 @@ # The prompt will use a Debian-style on the form # # relative-path-from-git-toplevel-dir bash-git-prompt-info -# HH:MM:SS ▶ +# HH:MM:SS User@Host ▶ # # The window title will have the form # relative-path-from-git-toplevel-dir # # Example usage: # if [ -f ~/.bash-git-prompt/gitprompt.sh ]; then -# GIT_PROMPT_THEME=Minimal +# GIT_PROMPT_THEME=Minimal_UserHost # source ~/.bash-git-prompt/gitprompt.sh # fi # -# Imbibinebe [https://github.com/imbibinebe] +# Gert Pellin [https://github.com/switch87] +# +# Based on Minimal by Imbibinebe [https://github.com/imbibinebe] ############################################################################## override_git_prompt_colors() { GIT_PROMPT_THEME_NAME="Minimal" @@ -35,6 +37,12 @@ override_git_prompt_colors() { } Time12a="\$(date +%H:%M:%S)" + if [ "$(id -u)" != "0" ]; then + UserHost_Color="${BoldGreen}" + else + UserHost_Color="${BoldRed}" + fi + GIT_PROMPT_BRANCH="${BoldMagenta}" # the git branch that is active in the current directory GIT_PROMPT_PREFIX="" # start of the git info string GIT_PROMPT_SUFFIX="" # the end of the git info string @@ -48,7 +56,7 @@ override_git_prompt_colors() { GIT_PROMPT_STASHED=" ${BoldCyan}⚑" # the number of stashed files/dir GIT_PROMPT_CLEAN=" ${BoldGreen}✔" # a colored flag indicating a "clean" repo - local gp_end="_LAST_COMMAND_INDICATOR_\n${BoldBlack}${Time12a} ${BoldGreen}$(whoami)@$(hostname)${ResetColor}" + local gp_end="_LAST_COMMAND_INDICATOR_\n${BoldBlack}${Time12a} ${UserHost_Color}$(whoami)@$(hostname)${ResetColor}" GIT_PROMPT_START_USER="" GIT_PROMPT_END_USER="${gp_end} ▶ " From 5e380e5048b6b6e9e2af17ac5a2f37cf7a5fc224 Mon Sep 17 00:00:00 2001 From: Gert Pellin Date: Tue, 14 Mar 2017 18:53:46 +0100 Subject: [PATCH 3/3] Changed theme-name inside file --- themes/Minimal_UserHost.bgptheme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/Minimal_UserHost.bgptheme b/themes/Minimal_UserHost.bgptheme index f95b97b..bb619b0 100644 --- a/themes/Minimal_UserHost.bgptheme +++ b/themes/Minimal_UserHost.bgptheme @@ -24,7 +24,7 @@ # Based on Minimal by Imbibinebe [https://github.com/imbibinebe] ############################################################################## override_git_prompt_colors() { - GIT_PROMPT_THEME_NAME="Minimal" + GIT_PROMPT_THEME_NAME="Minimal_UserHost" #Overrides the prompt_callback function used by bash-git-prompt function prompt_callback { @@ -66,4 +66,4 @@ override_git_prompt_colors() { GIT_PROMPT_COMMAND_FAIL="${BoldRed} ✘-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0 } -reload_git_prompt_colors "Minimal" +reload_git_prompt_colors "Minimal_UserHost"