Skip to content

Commit 14a5197

Browse files
authored
Merge pull request #16 from DiamondLightSource/cool-prompt
make prompt work reliably in narrow terminals -
2 parents 99e50b0 + 2b0928e commit 14a5197

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

.devcontainer/features/bash-config/config/bash-config-rc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,25 @@ export SAVEHIST=-1
1212
export HISTFILE=$CONFIG_FOLDER/.bash_eternal_history
1313
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
1414

15-
# bash theme - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
15+
# bash theme - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/dst.zsh-theme
1616
# from https://github.com/devcontainers/features/blob/main/src/common-utils/scripts/bash_theme_snippet.sh
1717
__bash_prompt() {
1818
local userpart='`export XIT=$? \
19-
&& [ ! -z "${GITHUB_USER:-}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER:-} " || echo -n "\[\033[0;32m\]\u " \
19+
&& echo -n "\u " \
2020
&& [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`'
2121
local gitbranch='`\
22-
if [ "$(git config --get devcontainers-theme.hide-status 2>/dev/null)" != 1 ] && [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \
2322
export BRANCH="$(git --no-optional-locks symbolic-ref --short HEAD 2>/dev/null || git --no-optional-locks rev-parse --short HEAD 2>/dev/null)"; \
2423
if [ "${BRANCH:-}" != "" ]; then \
25-
echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH:-}" \
26-
&& if [ "$(git config --get devcontainers-theme.show-dirty 2>/dev/null)" = 1 ] && \
27-
git --no-optional-locks ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \
24+
echo -n "\[\033[0;36m\](\[\033[1;32m\]${BRANCH:-}" \
25+
&& if git --no-optional-locks ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \
2826
echo -n " \[\033[1;33m\]✗"; \
2927
fi \
3028
&& echo -n "\[\033[0;36m\]) "; \
31-
fi; \
32-
fi`'
33-
local lightblue='\[\033[1;34m\]'
29+
fi`'
3430
local removecolor='\[\033[0m\]'
35-
PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ "
31+
local lightblue='\[\033[1;34m\]'
32+
local cyan='\[\033[0;36m\]'
33+
PS1="${lightblue}${userpart} ${cyan}\w ${gitbranch}${removecolor}\n\$ "
3634
unset -f __bash_prompt
3735
}
3836
__bash_prompt

0 commit comments

Comments
 (0)