From 2b0928ee50858c5e3f22debf9d66b0032d67ba63 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Thu, 6 Mar 2025 14:32:04 +0000 Subject: [PATCH] make prompt work reliably in narrow terminals - choose cool (temperature) colours --- .../features/bash-config/config/bash-config-rc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.devcontainer/features/bash-config/config/bash-config-rc b/.devcontainer/features/bash-config/config/bash-config-rc index ae61d91..b0c1c25 100644 --- a/.devcontainer/features/bash-config/config/bash-config-rc +++ b/.devcontainer/features/bash-config/config/bash-config-rc @@ -12,27 +12,25 @@ export SAVEHIST=-1 export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history export PROMPT_COMMAND="history -a; $PROMPT_COMMAND" -# bash theme - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme +# bash theme - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/dst.zsh-theme # from https://github.com/devcontainers/features/blob/main/src/common-utils/scripts/bash_theme_snippet.sh __bash_prompt() { local userpart='`export XIT=$? \ - && [ ! -z "${GITHUB_USER:-}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER:-} " || echo -n "\[\033[0;32m\]\u " \ + && echo -n "\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[0;36m\](\[\033[1;32m\]${BRANCH:-}" \ + && if 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\]' + fi`' local removecolor='\[\033[0m\]' - PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ " + local lightblue='\[\033[1;34m\]' + local cyan='\[\033[0;36m\]' + PS1="${lightblue}${userpart} ${cyan}\w ${gitbranch}${removecolor}\n\$ " unset -f __bash_prompt } __bash_prompt