Skip to content

Instantly share code, notes, and snippets.

@lordhasyim
Forked from specious/bender-bash-prompt
Created July 2, 2023 15: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 lordhasyim/72726fe57eb09e1d7c2fc080eb423e5a to your computer and use it in GitHub Desktop.
Save lordhasyim/72726fe57eb09e1d7c2fc080eb423e5a to your computer and use it in GitHub Desktop.
A fancy two-line #!/bin/bash prompt with $(git integration)
#
# Fancy two-line prompt with git integration
#
# ┌───=[ specious :: sharp -( 0 )-[ ~ ]-( master )
# └──(
#
git_current_head () {
git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD
}
git_dirty_mark () {
[[ -n $(git status -s | head -c 1) ]] && echo \*
}
show_git_prompt () {
git branch 2>/dev/null 1>&2 && echo -e "-( \e[34;1m$(git_current_head)$(git_dirty_mark)\e[31;1m )"
}
if [[ -n $(type -t git) ]] ; then
PS1="\$(show_git_prompt)"
else
PS1=
fi
PS1="
\[\e[31;1m\]┌───=[ \[\e[39;1m\]\u\[\e[31;1m\] :: \[\e[33;1m\]\h\[\e[31;1m\] ]-( \[\e[39;1m\]\j\[\e[31;1m\] )-[ \[\e[39;1m\]\w\[\e[31;1m\] ]$PS1
\[\e[31;1m\]└──( \[\e[0m\]"
# Display running command in GNU Screen window status
#
# In .screenrc, set: shelltitle "( |~"
#
# See: http://aperiodic.net/screen/title_examples#setting_the_title_to_the_name_of_the_running_program
case $TERM in screen*)
PS1=${PS1}'\[\033k\033\\\]'
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment