Last active
January 4, 2023 19:08
-
-
Save mohammad5305/ba3f353cb8d7197e20323a90d8fde1c2 to your computer and use it in GitHub Desktop.
sashimi fish prompt ported to bash
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
PROMPT_COMMAND=__prompt_command | |
__prompt_command() { | |
local EXIT="$?" # This needs to be first | |
PS1="" | |
cyan="\e[1;36m" | |
yellow="\e[0;33m" | |
red="\e[0;31m" | |
blue="\e[0;34m" | |
green="\e[1;32m" | |
normal="\e[0m" | |
cwd="\W" | |
dirty="$yellow ✗" | |
__git_ps1(){ | |
echo $(git symbolic-ref HEAD 2>/dev/null | sed -e 's|^refs/heads/||') | |
} | |
git_info() { | |
if [[ $(__git_ps1) ]] | |
then | |
if [[ $(__git_ps1 | grep master) ]] | |
then | |
git_prompt="git:($red%s$normal)" | |
else | |
git_prompt="git:($blue%s$normal)" | |
fi | |
printf $git_prompt $(__git_ps1) | |
fi | |
} | |
is_dirty() { | |
if [[ $(git status -s --ignore-submodules=dirty 2>/dev/null ) ]] | |
then | |
echo -e $dirty | |
fi | |
} | |
if [ $EXIT == 0 ]; then | |
initial_indicator="$green◆" | |
status_indicator="$normal❯$cyan❯$green❯" | |
else | |
initial_indicator="$red✖ $EXIT" | |
status_indicator="$red❯$red❯$red❯" | |
fi | |
PS1="$initial_indicator $cyan$cwd$normal \$(git_info)\$(is_dirty) $status_indicator$normal " | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment