Created
May 27, 2024 12:20
-
-
Save singe/a27e9d7951e728291bc1845b7b3fb2d3 to your computer and use it in GitHub Desktop.
My Oh My Zsh theme
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
# By Dominic White ( @[email protected] / @[email protected] ) | |
# | |
# I've been rolling this font for nearly two decades. I can't remember who wrote | |
# it originally, but I stole enough of it to not take any credit. I've just | |
# updated it here and there. The latest for Oh-My-Zsh | |
prompt_setup_singe() { | |
colour1="%{$fg[blue]%}" #line | |
colour2="%{$fg[green]%}" #directory | |
colour3="%{$fg[magenta]%}" #time, user, host | |
colour4="%{$fg_bold[grey]%}" #brackets | |
nocolour="%{$reset_color%}" #time, user, host | |
topleft="╭─" | |
botleft="╰─" | |
bracket1op="(" | |
bracket1cl=")" | |
bracket2op="[" | |
bracket2cl="]" | |
line="─" | |
clock="🕗 %T" | |
retval="❓%?" | |
user="👤 %n" | |
host="🏠 %m" | |
arrow="▶ " | |
hist="📜 %!" | |
newline=" | |
" | |
one="$colour1$topleft$colour4$bracket1op$colour2%~$colour4$bracket1cl$colour1$line" | |
two="$line$bracket2op$colour3$clock$retval $hist $user $host$colour1$bracket2cl$line$nocolour" | |
three="$colour1$botleft$nocolour$arrow" | |
padding="$colour1" | |
# Get the lines without the colour markers so we can calculate length | |
top_nocol=$(echo "$one$two" | perl -pe "s/%\{[^}]+\}//g") | |
precmd_functions+=(prompt_singe_precmd) | |
} | |
dynamic_elements() { | |
# Check if we're in a git folder | |
if [[ -n $(git_prompt_info) ]]; then | |
host="📝 $(git_prompt_info)" | |
fi | |
two="$line$bracket2op$colour3$clock$retval $hist $user $host$colour1$bracket2cl$line$nocolour" | |
# Check if we're in a python virtual environment | |
#local env="🐍 $(echo $VIRTUAL_ENV|grep -o [^\/]*$)" | |
#if [[ -n $VIRTUAL_ENV ]]; then | |
#two="$line$bracket2op$colour3$clock $retval $hist $user $env$colour1$bracket2cl$line$nocolour" | |
#else | |
#two="$line$bracket2op$colour3$clock $retval $hist $user $host$colour1$bracket2cl$line$nocolour" | |
#fi | |
top_nocol=$(echo "$one$two" | perl -pe "s/%\{[^}]+\}//g") | |
} | |
update_padding() { | |
# expand the variables like username and hostname to get "actual" length | |
local top_exp="$(print -P '$top_nocol')" | |
# work out how much padding we need | |
local size="$(( $COLUMNS - $#top_exp - 8 ))" | |
# generate padding | |
padding="$colour1" | |
for i in {0..$size}; do | |
padding="$padding$line" | |
done | |
} | |
prompt_singe_precmd() { | |
dynamic_elements | |
update_padding | |
PROMPT="$one$padding$two$newline$three" | |
} | |
prompt_setup_singe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment