Created
April 3, 2023 09:30
-
-
Save unkmas/10d3ab118ee1ac81532b7a02fb66eef7 to your computer and use it in GitHub Desktop.
This file contains 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
function felix_pwd_abbr { | |
base_pwd=$PWD | |
tilda_notation=${base_pwd//$HOME/\~} | |
pwd_list=(${(s:/:)tilda_notation}) | |
list_len=${#pwd_list} | |
if [[ $list_len -le 1 ]]; then | |
echo $tilda_notation | |
return | |
fi | |
if [[ ${pwd_list[1]} != '~' ]]; then | |
formed_pwd='/' | |
fi | |
firstchar=$(echo ${pwd_list[1]} | cut -c1) | |
if [[ $firstchar == '.' ]] ; then | |
firstchar=$(echo ${pwd_list[1]} | cut -c1,2) | |
fi | |
formed_pwd=${formed_pwd}$firstchar | |
for ((i=2; i <= $list_len; i++)) do | |
if [[ $i != ${list_len} ]]; then | |
firstchar=$(echo ${pwd_list[$i]} | cut -c1) | |
if [[ $firstchar == '.' ]] ; then | |
firstchar=$(echo ${pwd_list[$i]} | cut -c1,2) | |
fi | |
formed_pwd=${formed_pwd}/$firstchar | |
else | |
formed_pwd=${formed_pwd}/${pwd_list[$i]} | |
fi | |
done | |
echo $formed_pwd | |
return | |
} | |
function unkmas_git_branch_info { | |
local current_branch | |
current_branch=$(git_current_branch) | |
if [[ -n $current_branch ]]; then | |
echo "on %{$fg[green]%}$current_branch%{$reset_color%}" | |
fi | |
} | |
PROMPT='%{$fg[yellow]%}$(felix_pwd_abbr)%{$reset_color%} $(unkmas_git_branch_info) ⨯ ' | |
RPROMPT='%F{8}%D{%H:%M:%S}' | |
ZSH_HIGHLIGHT_STYLES[arg0]='none' | |
ZSH_HIGHLIGHT_STYLES[path]='fg=cyan,underline' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment