Skip to content

Instantly share code, notes, and snippets.

@raphink
Created August 21, 2019 18:04
Show Gist options
  • Save raphink/e3a2ac50cf279b2834a61a9f4ba62db7 to your computer and use it in GitHub Desktop.
Save raphink/e3a2ac50cf279b2834a61a9f4ba62db7 to your computer and use it in GitHub Desktop.
__lang_ps1() {
if test -f Gemfile || ls *.rb >/dev/null 2>&1; then
printf " \[\e[31m\]\\ue791"
fi
if test -f metadata.json || test -f Puppetfile || ls *.pp >/dev/null 2>&1; then
printf " \[\e[1;33m\]\u203a\[\e[97m\]p"
fi
if ls *.go >/dev/null 2>&1; then
printf " \[\e[36m\]\\ue724"
fi
if ls *.tf >/dev/null 2>&1; then
printf " \[\e[34m\]𝕐"
fi
if test -f Dockerfile; then
printf " \[\e[34m\]\\ue7b0"
fi
if test -f Jenkinsfile; then
printf " \[\e[35m\]\\ue767"
fi
if test -f .dropbox; then
printf " \[\e[34m\]\\ue707"
fi
if ls *.[jJ][pP][gG] >/dev/null 2>&1; then
printf " \[\e[34m\]ο€° "
fi
if ls *.[pP][nN][gG] >/dev/null 2>&1; then
printf " \[\e[34m\]ο€° "
fi
}
__prompt_ps1() {
local status=$?
PS1="\[\e[103;34m\] "
if [[ "$PWD" = "$HOME/Downloads"* ]]; then
PS1+=""
elif [[ "$PWD" = "$HOME"* ]]; then
PS1+=""
elif [[ "$PWD" = /media/* ]]; then
PS1+=""
else
PS1+=""
fi
PS1+=" \[\e[104;93m\]"
if [ $status -eq 0 ]; then
PS1+="ξ‚°"
else
PS1+=""
fi
PS1+="\[\e[37;1m\] \w "
local lang_ps=$(__lang_ps1)
local git_ps=$(__git_ps1)
if test -n "${lang_ps}${git_ps}"; then
__git_ps1 "${PS1} \[\e[49;94m\]ξ‚°\[\e[97m\]${lang_ps}\[\e[21;39m\]" "\[\e[00m\] "
else
PS1+=" \[\e[49;94m\]ξ‚°\[\e[00m\] "
fi
history -a
}
export GIT_PS1_SHOWDIRTYSTATE=1 GIT_PS1_SHOWSTASHSTATE=1 GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM=verbose GIT_PS1_DESCRIBE_STYLE=branch
export GIT_PS1_SHOWCOLORHINTS=1
export PROMPT_DIRTRIM=2
export PROMPT_COMMAND=__prompt_ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment