Created
November 27, 2025 19:11
-
-
Save wallentx/ad2fef18b76dbed123c9ce4e084e81bc to your computer and use it in GitHub Desktop.
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
| # Default OMZ theme for Archcraft | |
| NUM_DIR=2 | |
| DIR_PATH="%F{8}%K{8} %F{7} %F{7}%$NUM_DIR~ %{%k%}%F{8}" | |
| background_jobs="%(1j.%F{8}%K{8} %F{3} %{%k%}%F{8}%f.)" | |
| non_zero_return_value="%(0?..%F{8}%K{8} %F{1} %{%k%}%F{8}%f)" | |
| ZSH_THEME_GIT_PROMPT_PREFIX="%F{8}%K{8} %F{7} %K{8} " | |
| ZSH_THEME_GIT_PROMPT_SUFFIX=" %{%k%}%F{8} %{$reset_color%} " | |
| ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%} " | |
| function osx2_git_info { | |
| git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return | |
| local ref | |
| ref=$(git symbolic-ref --short HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) | |
| local dirty_status="" | |
| if [[ -n $(git status --porcelain --ignore-submodules 2> /dev/null) ]]; then | |
| dirty_status="$ZSH_THEME_GIT_PROMPT_DIRTY" | |
| fi | |
| echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref}${dirty_status}${ZSH_THEME_GIT_PROMPT_SUFFIX}" | |
| } | |
| autoload -U add-zsh-hook | |
| function osx2_theme_precmd { | |
| local left_part | |
| local right_part | |
| local git_info=$(osx2_git_info) | |
| if [[ "$USER" == "root" ]]; then | |
| left_part="%(?:%{$fg_bold[red]%}%{$fg_bold[green]%}%{$fg_bold[yellow]%} :%{$fg_bold[red]%} )" | |
| right_part='%{$fg[cyan]%} %c%{$reset_color%} $git_info' | |
| else | |
| left_part="%F{8}%K{8}%(?:%{$fg_bold[red]%}● %{$fg_bold[yellow]%}● %{$fg_bold[green]%}●%{%k%}%F{8}%f :%{$fg_bold[red]%}%{%k%}%F{8}%f )" | |
| right_part="$DIR_PATH $git_info $background_jobs" | |
| fi | |
| # Render prompt strings to get visual length | |
| local left_render=$(print -P "$left_part") | |
| local right_render=$(print -P "$right_part") | |
| # Strip ANSI color codes to calculate visual width | |
| local left_stripped=$(print -n "$left_render" | sed $'s/\e\[[0-9;]*m//g') | |
| local right_stripped=$(print -n "$right_render" | sed $'s/\e\[[0-9;]*m//g') | |
| # Calculate padding | |
| local pad=$(( COLUMNS - ${#left_stripped} - ${#right_stripped} )) | |
| if [[ $pad -lt 1 ]]; then pad=1; fi | |
| # Print the top bar | |
| print -P "${left_part}${(l:pad:: :)}${right_part}" | |
| } | |
| add-zsh-hook precmd osx2_theme_precmd | |
| PROMPT='%{$fg_bold[magenta]%}» %{$reset_color%} ' | |
| RPROMPT='' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment