Skip to content

Commit

Permalink
Merge pull request #1812 from tiagobarros99/fix-modern-theme
Browse files Browse the repository at this point in the history
modern theme, added virtualenv name display, changed first bracket and second bracket
  • Loading branch information
Noah Gorny authored Jan 26, 2021
2 parents 2a2741d + e80e29b commit 2db806f
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions themes/modern/modern.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,50 @@ SCM_HG_CHAR="${bold_red}☿${normal}"

case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
TITLEBAR=""
;;
esac

PS3=">> "

is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
if [ ! -z "$VIMRUNTIME" ]; then
echo "[${cyan}vim shell${normal}]"
fi
}

modern_scm_prompt() {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
if [ $CHAR = $SCM_NONE_CHAR ]; then
return
else
echo "[$(scm_char)][$(scm_prompt_info)]"
fi
}

prompt() {
if [ $? -ne 0 ]
then
# Yes, the indenting on these is weird, but it has to be like
# this otherwise it won't display properly.
detect_venv() {
python_venv=""
# Detect python venv
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="($PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV}) "
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv="($PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}")) "
fi
}

PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell)
${bold_red}└─▪${normal} "
prompt() {
if [ $? -ne 0 ]; then
PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n${bold_red}└─▪${normal} "
else
PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\W${normal}][$(battery_charge)]$(is_vim_shell)
└─▪ "
PS1="${TITLEBAR}┌─$(modern_scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n└─▪ "
fi
detect_venv
PS1+="${python_venv}${dir_color}"
}

PS2="└─▪ "



safe_append_prompt_command prompt

0 comments on commit 2db806f

Please sign in to comment.