Skip to content

Instantly share code, notes, and snippets.

@specious
Last active August 15, 2023 01:05
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save specious/8244801 to your computer and use it in GitHub Desktop.
Save specious/8244801 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
@specious
Copy link
Author

Fancy prompt for the bash command line with git integration.

bender-bash-prompt

@specious
Copy link
Author

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