Skip to content

Instantly share code, notes, and snippets.

@Dragod
Last active July 24, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dragod/e06fa0967a87c33f56cc11206bc69486 to your computer and use it in GitHub Desktop.
Save Dragod/e06fa0967a87c33f56cc11206bc69486 to your computer and use it in GitHub Desktop.
Personalized bash theme using bash_it (https://github.com/Bash-it/bash-it)
#!/usr/bin/env bash
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}"
SCM_GIT_CHAR="${bold_green}±${normal}"
SCM_SVN_CHAR="${bold_cyan}⑆${normal}"
SCM_HG_CHAR="${bold_red}☿${normal}"
# THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M"}
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
echo "[${cyan}vim shell${normal}]"
fi
}
modern_scm_prompt() {
CHAR=$(scm_char)
if [ $CHAR = $SCM_NONE_CHAR ]
then
return
else
echo "[$(scm_char)][$(scm_prompt_info)]"
fi
}
function set_prompt_symbol () {
if test $1 -eq 0 ; then
PROMPT_SYMBOL=">_"
else
PROMPT_SYMBOL="${orange}>_${normal}"
fi
}
prompt() {
set_prompt_symbol $?
if [ $? -ne 0 ]
then
# Yes, the indenting on these is weird, but it has to be like
# this otherwise it won't display properly.
PS1="${TITLEBAR}${bold_red}${reset_color}$(modern_scm_prompt)[${cyan}\W${normal}]${bold_red}${normal} "
else
# PS1="${purple}$(clock_prompt)${TITLEBAR} Path:[${cyan}\W${normal}] Branch:[${purple}$(scm_char)] [$(scm_prompt_info)${normal}] ${normal}[${cyan}\s ${normal}] ${normal}${purple}${PROMPT_SYMBOL}${white} "
# https://stackoverflow.com/questions/21517281/ps1-command-substitution-fails-when-containing-newlines-on-msys-bash
# Okay I solved it for double quotes "bla \n bla" becomes "bla "$'\n'" bla". Solved by good old trial and error, and reading about Bash escaping... – JustGoscha Apr 11 '16 at 15:33
# Check if the folder has a git repos
if git rev-parse --git-dir > /dev/null 2>&1; then
# Has git
PS1="\n⌚ ${yellow}$(clock_prompt) → ${TITLEBAR}Path:[${cyan}\W${normal}]  Branch:[${cyan}$(scm_prompt_info)${normal}] ${normal} ${normal}${purple}"$'\n'"${PROMPT_SYMBOL}${white} "
else
# Not a Git folder
PS1="\n⌚ ${yellow}$(clock_prompt) → ${TITLEBAR}Path:[${cyan}\W${normal}] ${normal}${purple}"$'\n'"${PROMPT_SYMBOL}${white} "
fi
fi
}
safe_append_prompt_command prompt
# Use this if you want to show what shell is used as well "bash" will print on the prompt as well
# PS1="\n${yellow}$(clock_prompt) >${TITLEBAR} Path:[${cyan}\W${normal}] Branch:[${cyan}$(scm_prompt_info)${normal}] ${normal}[${cyan}\s${normal}] ${normal}${purple}"$'\n'"${PROMPT_SYMBOL}${white} "
# PS1="${bold_orange}${PYTHON_VIRTUALENV}${reset_color}${bold_green}[\w]${bold_blue}\[$(scm_prompt_info)\]${normal} \n${PROMPT_SYMBOL} "
@Dragod
Copy link
Author

Dragod commented Feb 28, 2019

If some font are missing, install "Fira Code" & "Inconsolata fo Powerline" ten search for the font with "character mapper" tools in wondows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment