Skip to content

Commit 6a606da

Browse files
committed
Merge pull request #210 from ogr3/single-line-themes-simplified
Changed the themes to properly override Default theme
2 parents 02f8c10 + a2182bb commit 6a606da

4 files changed

+55
-299
lines changed

themes/Single_line.bgptheme

+6-101
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,11 @@
11
# This is an alternative approach. Single line in git repo.
2+
override_git_prompt_colors() {
3+
GIT_PROMPT_THEME_NAME="Single_line"
24

3-
unset_git_prompt_colors() {
4-
unset Time12a
5-
unset PathShort
6-
unset GIT_PROMPT_PREFIX
7-
unset GIT_PROMPT_SUFFIX
8-
unset GIT_PROMPT_SEPARATOR
9-
unset GIT_PROMPT_BRANCH
10-
unset GIT_PROMPT_STAGED
11-
unset GIT_PROMPT_CONFLICTS
12-
unset GIT_PROMPT_CHANGED
13-
unset GIT_PROMPT_REMOTE
14-
unset GIT_PROMPT_UNTRACKED
15-
unset GIT_PROMPT_STASHED
16-
unset GIT_PROMPT_CLEAN
17-
unset GIT_PROMPT_COMMAND_OK
18-
unset GIT_PROMPT_COMMAND_FAIL
19-
unset GIT_PROMPT_VIRTUALENV
20-
unset GIT_PROMPT_UPSTREAM
21-
unset GIT_PROMPT_START_USER
22-
unset GIT_PROMPT_START_ROOT
23-
unset GIT_PROMPT_END_USER
24-
unset GIT_PROMPT_END_ROOT
25-
unset GIT_PROMPT_SYMBOLS_AHEAD
26-
unset GIT_PROMPT_SYMBOLS_BEHIND
27-
unset GIT_PROMPT_SYMBOLS_PREHASH
28-
unset GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING
5+
GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${White}${Time12a}${ResetColor} ${BoldYellow}${PathShort}${ResetColor}"
6+
GIT_PROMPT_END_USER="${ResetColor} $ "
7+
GIT_PROMPT_END_ROOT="${BoldRed} # "
298
}
309

31-
define_helpers() {
32-
Time12a="\$(date +%H:%M)"
33-
PathShort="\w";
34-
}
35-
36-
define_undefined_git_prompt_colors() {
37-
if [[ -z ${GIT_PROMPT_THEME_NAME} ]]; then GIT_PROMPT_THEME_NAME="Single_line"; fi
38-
39-
# These are the color definitions used by gitprompt.sh
40-
if [[ -z ${GIT_PROMPT_PREFIX} ]]; then GIT_PROMPT_PREFIX="["; fi # start of the git info string
41-
if [[ -z ${GIT_PROMPT_SUFFIX} ]]; then GIT_PROMPT_SUFFIX="]"; fi # the end of the git info string
42-
if [[ -z ${GIT_PROMPT_SEPARATOR} ]]; then GIT_PROMPT_SEPARATOR="|"; fi # separates each item
43-
44-
if [[ -z ${GIT_PROMPT_BRANCH} ]]; then GIT_PROMPT_BRANCH="${Magenta}"; fi # the git branch that is active in the current directory
45-
if [[ -z ${GIT_PROMPT_STAGED} ]]; then GIT_PROMPT_STAGED="${Red}●"; fi # the number of staged files/directories
46-
if [[ -z ${GIT_PROMPT_CONFLICTS} ]]; then GIT_PROMPT_CONFLICTS="${Red}✖ "; fi # the number of files in conflict
47-
if [[ -z ${GIT_PROMPT_CHANGED} ]]; then GIT_PROMPT_CHANGED="${Blue}✚ "; fi # the number of changed files
48-
49-
if [[ -z ${GIT_PROMPT_REMOTE} ]]; then GIT_PROMPT_REMOTE=" "; fi # the remote branch name (if any) and the symbols for ahead and behind
50-
if [[ -z ${GIT_PROMPT_UNTRACKED} ]]; then GIT_PROMPT_UNTRACKED="${Cyan}…"; fi # the number of untracked files/dirs
51-
if [[ -z ${GIT_PROMPT_STASHED} ]]; then GIT_PROMPT_STASHED="${BoldBlue}⚑ "; fi # the number of stashed files/dir
52-
if [[ -z ${GIT_PROMPT_CLEAN} ]]; then GIT_PROMPT_CLEAN="${BoldGreen}✔"; fi # a colored flag indicating a "clean" repo
53-
54-
# For the command indicator, the placeholder _LAST_COMMAND_STATE_
55-
# will be replaced with the exit code of the last command
56-
# e.g.
57-
# GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0
58-
# GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0
59-
60-
if [[ -z ${GIT_PROMPT_COMMAND_OK} ]]; then GIT_PROMPT_COMMAND_OK="${Green}✔"; fi # indicator if the last command returned with an exit code of 0
61-
if [[ -z ${GIT_PROMPT_COMMAND_FAIL} ]]; then GIT_PROMPT_COMMAND_FAIL="${Red}✘"; fi # indicator if the last command returned with an exit code of other than 0
62-
63-
# Possible to change which command is used to create git status information
64-
# There are three options:
65-
# 1) gitstatus.sh (uses git status --branch --porcelain - fast, requires git > 1.7.10)
66-
# 2) gitstatus_pre-1.7.10.sh (Uses a variety of git commands and pipes - slower, works with older git clients)
67-
# 3) gitstatus.py (Unsupported, lack features found in the bash versions)
68-
if [[ -z ${GIT_PROMPT_STATUS_COMMAND} ]]; then GIT_PROMPT_STATUS_COMMAND="gitstatus.sh"; fi # Point out the command to get the git status from
69-
70-
# template for displaying the current virtual environment
71-
# use the placeholder _VIRTUALENV_ will be replaced with
72-
# the name of the current virtual environment (currently CONDA and VIRTUAL_ENV)
73-
if [[ -z ${GIT_PROMPT_VIRTUALENV} ]]; then GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) "; fi
74-
75-
# template for displaying the current remote tracking branch
76-
# use the placeholder _UPSTREAM_ will be replaced with
77-
# the name of the current remote tracking branch
78-
if [[ -z ${GIT_PROMPT_UPSTREAM} ]]; then GIT_PROMPT_UPSTREAM=" {${Blue}_UPSTREAM_${ResetColor}}"; fi
79-
80-
# _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL
81-
if [[ -z ${GIT_PROMPT_START_USER} ]]; then GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${White}${Time12a}${ResetColor} ${BoldYellow}${PathShort}${ResetColor}"; fi
82-
if [[ -z ${GIT_PROMPT_START_ROOT} ]]; then GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}"; fi
83-
if [[ -z ${GIT_PROMPT_END_USER} ]]; then GIT_PROMPT_END_USER="${ResetColor} $ "; fi
84-
if [[ -z ${GIT_PROMPT_END_ROOT} ]]; then GIT_PROMPT_END_ROOT="${BoldRed} # "; fi
85-
86-
# Please do not add colors to these symbols
87-
if [[ -z ${GIT_PROMPT_SYMBOLS_AHEAD} ]]; then GIT_PROMPT_SYMBOLS_AHEAD="↑·"; fi # The symbol for "n versions ahead of origin"
88-
if [[ -z ${GIT_PROMPT_SYMBOLS_BEHIND} ]]; then GIT_PROMPT_SYMBOLS_BEHIND="↓·"; fi # The symbol for "n versions behind of origin"
89-
if [[ -z ${GIT_PROMPT_SYMBOLS_PREHASH} ]]; then GIT_PROMPT_SYMBOLS_PREHASH=":"; fi # Written before hash of commit, if no name could be found
90-
if [[ -z ${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING} ]]; then GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="L"; fi # This symbol is written after the branch, if the branch is not tracked
91-
}
92-
93-
# call only from theme file
94-
reload_git_prompt_colors() {
95-
if [[ "${GIT_PROMPT_THEME_NAME}" != $1 ]]; then
96-
unset_git_prompt_colors
97-
define_helpers
98-
override_git_prompt_colors
99-
define_undefined_git_prompt_colors
100-
fi
101-
}
10+
reload_git_prompt_colors "Single_line"
10211

103-
if [[ "${GIT_PROMPT_THEME}" == "Single_line" && "${GIT_PROMPT_THEME_NAME}" != "Single_line" ]]; then
104-
define_helpers
105-
define_undefined_git_prompt_colors
106-
fi
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This is an alternative approach. Single line in git repo.
2+
override_git_prompt_colors() {
3+
GIT_PROMPT_THEME_NAME="Single_line_NoExitState"
4+
5+
GIT_PROMPT_COMMAND_FAIL="${Red}✘"
6+
GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${White}${Time12a}${ResetColor} ${BoldYellow}${PathShort}${ResetColor}"
7+
GIT_PROMPT_END_USER="${ResetColor} $ "
8+
GIT_PROMPT_END_ROOT="${BoldRed} # "
9+
}
10+
11+
reload_git_prompt_colors "Single_line_NoExitState"
12+

themes/Single_line_Solarized.bgptheme

+17-97
Original file line numberDiff line numberDiff line change
@@ -4,111 +4,31 @@
44
# without the indicator of the last command state
55
# tweaked for Ubuntu terminal fonts
66

7-
unset_git_prompt_colors() {
8-
unset Time12a
9-
unset PathShort
10-
unset GIT_PROMPT_PREFIX
11-
unset GIT_PROMPT_SUFFIX
12-
unset GIT_PROMPT_SEPARATOR
13-
unset GIT_PROMPT_BRANCH
14-
unset GIT_PROMPT_STAGED
15-
unset GIT_PROMPT_CONFLICTS
16-
unset GIT_PROMPT_CHANGED
17-
unset GIT_PROMPT_REMOTE
18-
unset GIT_PROMPT_UNTRACKED
19-
unset GIT_PROMPT_STASHED
20-
unset GIT_PROMPT_CLEAN
21-
unset GIT_PROMPT_COMMAND_OK
22-
unset GIT_PROMPT_COMMAND_FAIL
23-
unset GIT_PROMPT_VIRTUALENV
24-
unset GIT_PROMPT_UPSTREAM
25-
unset GIT_PROMPT_START_USER
26-
unset GIT_PROMPT_START_ROOT
27-
unset GIT_PROMPT_END_USER
28-
unset GIT_PROMPT_END_ROOT
29-
unset GIT_PROMPT_SYMBOLS_AHEAD
30-
unset GIT_PROMPT_SYMBOLS_BEHIND
31-
unset GIT_PROMPT_SYMBOLS_PREHASH
32-
unset GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING
33-
}
34-
357
define_helpers() {
368
PathShort="${BoldBlue}\u:${Cyan}\W"
379
}
3810

39-
define_undefined_git_prompt_colors() {
40-
if [[ -z ${GIT_PROMPT_THEME_NAME} ]]; then GIT_PROMPT_THEME_NAME="Single_line_Solarized"; fi
41-
42-
# These are the color definitions used by gitprompt.sh
43-
if [[ -z ${GIT_PROMPT_PREFIX} ]]; then GIT_PROMPT_PREFIX="[ "; fi # start of the git info string
44-
if [[ -z ${GIT_PROMPT_SUFFIX} ]]; then GIT_PROMPT_SUFFIX=" ]"; fi # the end of the git info string
45-
if [[ -z ${GIT_PROMPT_SEPARATOR} ]]; then GIT_PROMPT_SEPARATOR=" |"; fi # separates each item
46-
47-
if [[ -z ${GIT_PROMPT_BRANCH} ]]; then GIT_PROMPT_BRANCH="${Magenta}"; fi # the git branch that is active in the current directory
48-
if [[ -z ${GIT_PROMPT_STAGED} ]]; then GIT_PROMPT_STAGED=" ${Yellow}●${ResetColor}"; fi # the number of staged files/directories
49-
if [[ -z ${GIT_PROMPT_CONFLICTS} ]]; then GIT_PROMPT_CONFLICTS=" ${Red}✖ ${ResetColor}"; fi # the number of files in conflict
50-
if [[ -z ${GIT_PROMPT_CHANGED} ]]; then GIT_PROMPT_CHANGED=" ${Blue}✚ ${ResetColor}"; fi # the number of changed files
51-
52-
if [[ -z ${GIT_PROMPT_REMOTE} ]]; then GIT_PROMPT_REMOTE=" "; fi # the remote branch name (if any) and the symbols for ahead and behind
53-
if [[ -z ${GIT_PROMPT_UNTRACKED} ]]; then GIT_PROMPT_UNTRACKED=" ${Cyan}…${ResetColor}"; fi # the number of untracked files/dirs
54-
if [[ -z ${GIT_PROMPT_STASHED} ]]; then GIT_PROMPT_STASHED=" ${BoldMagenta}⚑ ${ResetColor}"; fi # the number of stashed files/dir
55-
if [[ -z ${GIT_PROMPT_CLEAN} ]]; then GIT_PROMPT_CLEAN=" ${Green}✔ ${ResetColor}"; fi # a colored flag indicating a "clean" repo
56-
57-
# For the command indicator, the placeholder _LAST_COMMAND_STATE_
58-
# will be replaced with the exit code of the last command
59-
# e.g.
60-
# GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0
61-
# GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0
62-
63-
if [[ -z ${GIT_PROMPT_COMMAND_OK} ]]; then GIT_PROMPT_COMMAND_OK="${Green}✔"; fi # indicator if the last command returned with an exit code of 0
64-
if [[ -z ${GIT_PROMPT_COMMAND_FAIL} ]]; then GIT_PROMPT_COMMAND_FAIL="${Red}✘"; fi # indicator if the last command returned with an exit code of other than 0
11+
override_git_prompt_colors() {
12+
GIT_PROMPT_THEME_NAME="Single_line_Solarized"
6513

66-
# Possible to change which command is used to create git status information
67-
# There are three options:
68-
# 1) gitstatus.sh (uses git status --branch --porcelain - fast, requires git > 1.7.10)
69-
# 2) gitstatus_pre-1.7.10.sh (Uses a variety of git commands and pipes - slower, works with older git clients)
70-
# 3) gitstatus.py (Unsupported, lack features found in the bash versions)
71-
if [[ -z ${GIT_PROMPT_STATUS_COMMAND} ]]; then GIT_PROMPT_STATUS_COMMAND="gitstatus.sh"; fi # Point out the command to get the git status from
7214

73-
# template for displaying the current virtual environment
74-
# use the placeholder _VIRTUALENV_ will be replaced with
75-
# the name of the current virtual environment (currently CONDA and VIRTUAL_ENV)
76-
if [[ -z ${GIT_PROMPT_VIRTUALENV} ]]; then GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) "; fi
15+
GIT_PROMPT_PREFIX="[ "
16+
GIT_PROMPT_SUFFIX=" ]"
17+
GIT_PROMPT_SEPARATOR=" |"
18+
GIT_PROMPT_STAGED=" ${Yellow}● ${ResetColor}"
19+
GIT_PROMPT_CONFLICTS=" ${Red}✖ ${ResetColor}"
20+
GIT_PROMPT_CHANGED=" ${Blue}✚ ${ResetColor}"
21+
GIT_PROMPT_UNTRACKED=" ${Cyan}…${ResetColor}"
22+
GIT_PROMPT_STASHED=" ${BoldMagenta}⚑ ${ResetColor}"
23+
GIT_PROMPT_CLEAN=" ${Green}✔ ${ResetColor}"
7724

78-
# template for displaying the current remote tracking branch
79-
# use the placeholder _UPSTREAM_ will be replaced with
80-
# the name of the current remote tracking branch
81-
if [[ -z ${GIT_PROMPT_UPSTREAM} ]]; then GIT_PROMPT_UPSTREAM=" {${Blue}_UPSTREAM_${ResetColor}}"; fi
25+
GIT_PROMPT_COMMAND_FAIL="${Red}✘"
8226

83-
# _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL
84-
if [[ -z ${GIT_PROMPT_START_USER} ]]; then GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}"; fi
27+
GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}"
28+
GIT_PROMPT_END_USER="${BoldBlue} ➭ ${ResetColor}"
29+
GIT_PROMPT_END_ROOT="${BoldRed} # "
8530

86-
if [[ -z ${GIT_PROMPT_START_ROOT} ]]; then GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}"; fi
87-
if [[ -z ${GIT_PROMPT_END_USER} ]]; then GIT_PROMPT_END_USER="${BoldBlue} ➭ ${ResetColor}"; fi # Reset color for user
88-
if [[ -z ${GIT_PROMPT_END_ROOT} ]]; then GIT_PROMPT_END_ROOT="${BoldRed} # "; fi # Bright red for Root
89-
90-
# Please do not add colors to these symbols
91-
if [[ -z ${GIT_PROMPT_SYMBOLS_AHEAD} ]]; then GIT_PROMPT_SYMBOLS_AHEAD="↑·"; fi # The symbol for "n versions ahead of origin"
92-
if [[ -z ${GIT_PROMPT_SYMBOLS_BEHIND} ]]; then GIT_PROMPT_SYMBOLS_BEHIND="↓·"; fi # The symbol for "n versions behind of origin"
93-
if [[ -z ${GIT_PROMPT_SYMBOLS_PREHASH} ]]; then GIT_PROMPT_SYMBOLS_PREHASH=":"; fi # Written before hash of commit, if no name could be found
94-
if [[ -z ${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING} ]]; then GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="✭"; fi # This symbol is written after the branch, if the branch is not tracked
95-
}
96-
97-
# call only from theme file
98-
reload_git_prompt_colors() {
99-
if [[ "${GIT_PROMPT_THEME_NAME}" != $1 ]]; then
100-
unset_git_prompt_colors
101-
define_helpers
102-
override_git_prompt_colors
103-
define_undefined_git_prompt_colors
104-
fi
31+
GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="✭"
10532
}
10633

107-
if [[ "${GIT_PROMPT_THEME}" == "Single_line_Solarized" && "${GIT_PROMPT_THEME_NAME}" != "Single_line_Solarized" ]]; then
108-
define_helpers
109-
define_undefined_git_prompt_colors
110-
fi
111-
112-
overide_git_prompt_colors() {
113-
GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="✭"
114-
}
34+
reload_git_prompt_colors "Single_line_Solarized"

0 commit comments

Comments
 (0)