aboutsummaryrefslogtreecommitdiff
path: root/src/common-utils/scripts/bash_theme_snippet.sh
diff options
context:
space:
mode:
authorChuck Lantz <clantz@microsoft.com>2022-12-16 20:47:21 +0300
committerGitHub <noreply@github.com>2022-12-16 20:47:21 +0300
commitbf058dc49492b3a102a28ed25764a517fcebfb40 (patch)
tree6ccc831064fab57ea6fa2f0c530202ac0d73ff08 /src/common-utils/scripts/bash_theme_snippet.sh
parent7fa90110d762797cc0b1c2fe8fcc028c9b813d56 (diff)
Multi-distro support for common script, refactor, fixes (#326)
Diffstat (limited to 'src/common-utils/scripts/bash_theme_snippet.sh')
-rw-r--r--src/common-utils/scripts/bash_theme_snippet.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/common-utils/scripts/bash_theme_snippet.sh b/src/common-utils/scripts/bash_theme_snippet.sh
new file mode 100644
index 0000000..a028e4b
--- /dev/null
+++ b/src/common-utils/scripts/bash_theme_snippet.sh
@@ -0,0 +1,25 @@
+
+# bash theme - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
+__bash_prompt() {
+ local userpart='`export XIT=$? \
+ && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \
+ && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`'
+ local gitbranch='`\
+ if [ "$(git config --get devcontainers-theme.hide-status 2>/dev/null)" != 1 ] && [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \
+ export BRANCH=$(git --no-optional-locks symbolic-ref --short HEAD 2>/dev/null || git --no-optional-locks rev-parse --short HEAD 2>/dev/null); \
+ if [ "${BRANCH}" != "" ]; then \
+ echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \
+ && if [ "$(git config --get devcontainers-theme.show-dirty 2>/dev/null)" = 1 ] && \
+ git --no-optional-locks ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \
+ echo -n " \[\033[1;33m\]✗"; \
+ fi \
+ && echo -n "\[\033[0;36m\]) "; \
+ fi; \
+ fi`'
+ local lightblue='\[\033[1;34m\]'
+ local removecolor='\[\033[0m\]'
+ PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ "
+ unset -f __bash_prompt
+}
+__bash_prompt
+export PROMPT_DIRTRIM=4