From 775607d764bdd8d68a907bf4e35ad8ffce1bd192 Mon Sep 17 00:00:00 2001 From: Adam Kruszewski Date: Sat, 13 May 2023 10:49:52 +0200 Subject: [PATCH] Initial commit --- min-percent.zsh-theme | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 min-percent.zsh-theme diff --git a/min-percent.zsh-theme b/min-percent.zsh-theme new file mode 100644 index 0000000..aa154c7 --- /dev/null +++ b/min-percent.zsh-theme @@ -0,0 +1,35 @@ +# min-percent zsh theme - a minimalist zsh theme with a % or # sign as the prompt terminator +# based on pi.zsh-theme (https://github.com/tobyjamesthomas/pi) by Toby Thomas +# +# Extra space after unicode emoji character (⚠) is needed for most terminal emulators +# alacritty, gnome-terminal, vterm based, etc. +# Without it the emoji character is rendered partially on the next symbol -- the problem being unicode +# emojis being treated as single width character but they are usually double. + +PROMPT='%{$fg_bold[blue]%}$(get_pwd)%{$reset_color%} $(git_prompt_info)%(?:%{$fg_bold[red]%}%#:%{$fg_bold[red]%}⚠ %#) %{$reset_color%}' + +# modified function taken from shashankmehta's dot files +# (https://github.com/shashankmehta) +function get_pwd(){ + git_root=$PWD + while [[ $git_root != / && ! -e $git_root/.git ]]; do + git_root=$git_root:h + done + if [[ $git_root = / ]]; then + unset git_root + # full prompt: + # prompt_short_dir=%~ + + # shortened prompt: + prompt_short_dir=%(4~|%-1~/…/%2~|%3~) + else + parent=${git_root%\/*} + prompt_short_dir=" ${PWD#$parent/}" + fi + echo $prompt_short_dir +} + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[green]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[magenta]%}⛌ " +ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}⬥ "