diff options
author | Santo Cariotti <santo@dcariotti.me> | 2025-03-12 15:17:10 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2025-03-12 15:19:00 +0100 |
commit | 297beaae685762ecf3c59c7c26296e377e64e0fd (patch) | |
tree | bbcb127ce6ff471c1e4bd2067518574c4eb9cbff | |
parent | aa89006af82956711e5d0b57c73d4859ce2969fc (diff) |
Use zsh theme instead of Starship
-rw-r--r-- | dot_oh-my-zsh/themes/jon.zsh-theme | 113 | ||||
-rw-r--r-- | dot_zshrc | 6 |
2 files changed, 115 insertions, 4 deletions
diff --git a/dot_oh-my-zsh/themes/jon.zsh-theme b/dot_oh-my-zsh/themes/jon.zsh-theme new file mode 100644 index 0000000..e06f45d --- /dev/null +++ b/dot_oh-my-zsh/themes/jon.zsh-theme @@ -0,0 +1,113 @@ +autoload -Uz colors && colors + +# Git status symbols +ZSH_THEME_GIT_PROMPT_CONFLICTED='⚠' +ZSH_THEME_GIT_PROMPT_AHEAD='⇡' +ZSH_THEME_GIT_PROMPT_BEHIND='⇣' +ZSH_THEME_GIT_PROMPT_DIVERGED='⇕' +# ZSH_THEME_GIT_PROMPT_UP_TO_DATE='✓' +ZSH_THEME_GIT_PROMPT_UNTRACKED='?' +ZSH_THEME_GIT_PROMPT_STASHED='$' +ZSH_THEME_GIT_PROMPT_MODIFIED='!' +ZSH_THEME_GIT_PROMPT_STAGED='+' +# ZSH_THEME_GIT_PROMPT_RENAMED='»' +# ZSH_THEME_GIT_PROMPT_DELETED='✘' +ZSH_THEME_GIT_PROMPT_TYPECHANGED='~' + +# Function to get git branch name +git_branch_name() { + local branch=$(git symbolic-ref HEAD 2> /dev/null) + if [[ -n "$branch" ]]; then + echo "${branch#refs/heads/}" + else + # If not on a branch, get the hash + echo "$(git rev-parse --short HEAD 2> /dev/null)" + fi +} + +# Function to get git status symbols +git_prompt_status() { + local git_status="" + + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + if [[ -n $(git ls-files --other --exclude-standard 2>/dev/null) ]]; then + git_status+="${ZSH_THEME_GIT_PROMPT_UNTRACKED}" + fi + if $(git rev-parse --verify refs/stash >/dev/null 2>&1); then + git_status+="${ZSH_THEME_GIT_PROMPT_STASHED}" + fi + if $(git diff --name-status 2>/dev/null | grep -q "M"); then + git_status+="${ZSH_THEME_GIT_PROMPT_MODIFIED}" + fi + if $(git diff --staged --name-status 2>/dev/null | grep -q "M"); then + git_status+="${ZSH_THEME_GIT_PROMPT_STAGED}" + fi + # if $(git diff --name-status 2>/dev/null | grep -q "R"); then + # git_status+="${ZSH_THEME_GIT_PROMPT_RENAMED}" + # fi + # if $(git diff --name-status 2>/dev/null | grep -q "D"); then + # git_status+="${ZSH_THEME_GIT_PROMPT_DELETED}" + # fi + if $(git diff --name-status 2>/dev/null | grep -q "T"); then + git_status+="${ZSH_THEME_GIT_PROMPT_TYPECHANGED}" + fi + if $(git status 2>/dev/null | grep -q "Unmerged"); then + git_status+="${ZSH_THEME_GIT_PROMPT_CONFLICTED}" + fi + if $(git status 2>/dev/null | grep -q "Your branch is ahead"); then + git_status+="${ZSH_THEME_GIT_PROMPT_AHEAD}" + fi + if $(git status 2>/dev/null | grep -q "Your branch is behind"); then + git_status+="${ZSH_THEME_GIT_PROMPT_BEHIND}" + fi + if $(git status 2>/dev/null | grep -q "have diverged"); then + git_status+="${ZSH_THEME_GIT_PROMPT_DIVERGED}" + fi + # if [[ -z "$git_status" && -z $(git status --porcelain 2>/dev/null) ]]; then + # git_status+="${ZSH_THEME_GIT_PROMPT_UP_TO_DATE}" + # fi + fi + echo "$git_status" +} + +# Function to get git info with symbols +git_prompt_info() { + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + local branch=$(git_branch_name) + local git_status_symbols=$(git_prompt_status) + echo "[${branch}${git_status_symbols}]" + fi +} + +# Function to get path (full path or truncated if in git repo) +get_path_info() { + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + # In git repo - show repo name + path within repo + local git_root=$(git rev-parse --show-toplevel) + local git_dirname=$(basename "$git_root") + local path_within_repo="${PWD#$git_root}" + + if [[ -z "$path_within_repo" ]]; then + # We're in the git root directory + echo "$git_dirname" + else + # We're in a subdirectory of the git repo + echo "$git_dirname$path_within_repo" + fi + else + # Not in git repo - show full path relative to $HOME + echo "%~" + fi +} + +# Basic prompt +PROMPT='%{$fg_bold[black]%}[%*] ' # Show current time in HH:MM +PROMPT+='%{$fg[yellow]%}%n%{$reset_color%}@%F{#D7005F}%m' +if [[ "$PWD" != "$HOME" ]]; then + PROMPT+='%{$fg_bold[black]%}:%{$fg[yellow]%}$(get_path_info) ' # Dynamic path display +fi + +# Add git info to prompt +PROMPT+='%F{#D7005F}$(git_prompt_info) ' # Git prompt with symbols +PROMPT+='%{$fg[red]%}| ' # Pipe separator +PROMPT+='%{$reset_color%}' # Reset color @@ -1,7 +1,7 @@ # now use Starship instead of oh-my-zsh theme export ZSH="/home/santo/.oh-my-zsh" # ZSH_THEME="pure" -# ZSH_THEME="dpoggi" +ZSH_THEME="jon" plugins=( git zsh-autosuggestions @@ -13,7 +13,7 @@ plugins=( source $ZSH/oh-my-zsh.sh -eval "$(starship init zsh)" +# eval "$(starship init zsh)" # export NVM_DIR="$HOME/.nvm" # [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm @@ -82,8 +82,6 @@ case ":$PATH:" in *":$PNPM_HOME:"*) ;; *) export PATH="$PNPM_HOME:$PATH" ;; esac - -alias npm=pnpm # pnpm end # UV |