Last active
March 2, 2025 05:55
-
-
Save specious/8244801 to your computer and use it in GitHub Desktop.
A fancy two-line bash prompt with git integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 currently 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
zsh version here: https://github.com/specious/bender