diff options
Diffstat (limited to 'zsh')
| -rw-r--r-- | zsh/functions/status.zsh | 41 | ||||
| -rw-r--r-- | zsh/modules/prompt.zsh | 2 |
2 files changed, 41 insertions, 2 deletions
diff --git a/zsh/functions/status.zsh b/zsh/functions/status.zsh index 3062ce8..f7f38ce 100644 --- a/zsh/functions/status.zsh +++ b/zsh/functions/status.zsh @@ -29,11 +29,50 @@ function node_info { echo "%{%F{yellow}%}js%{%F{black}%} ${nodeinfo:-no}" } +function jj_info { + # Check if we're in a jj repo + if ! jj root &> /dev/null; then + return + fi + + # Get current change ID (short form) + change=$(jj log -r @ --no-graph -T 'change_id.shortest()' 2> /dev/null) + + if [ ! -z "$change" ]; then + echo -n "@%F{cyan}$change%f" + + # Get status output + status_output=$(jj status 2> /dev/null) + + # Modified files + if echo "$status_output" | rg -q '^M '; then + echo -n "%{%F{yellow}%}△%f" + fi + + # Added files + if echo "$status_output" | rg -q '^A '; then + echo -n "%{%F{green}%}+%f" + fi + + # Deleted files + if echo "$status_output" | rg -q '^D '; then + echo -n "%{%F{red}%}×%f" + fi + + # Unknown/untracked files + if echo "$status_output" | rg -q '^\? '; then + echo -n "%{%F{magenta}%}+%f" + fi + + echo -n "%f" + fi +} + function git_info { branch=$(git branch --show-current 2> /dev/null) if [ ! -z $branch ]; then - echo -n "@%F{cyan}$branch%f" + echo -n "@%F{cyan}$branch%f" status_output=$(git status --short) diff --git a/zsh/modules/prompt.zsh b/zsh/modules/prompt.zsh index 5b79b3e..9b41e32 100644 --- a/zsh/modules/prompt.zsh +++ b/zsh/modules/prompt.zsh @@ -46,7 +46,7 @@ function prompt_setup { # Define prompts. PROMPT=' -%{%F{black}%}$(env_info)%{%F{magenta}%}%n%{%F{8}%}@%{%F{cyan}%}$(hostname -s)%{%f%} %{%B%F{blue}%}${PWD/#$HOME/~}%{%f%b%}$(git_info)%{%f%} + %{%F{black}%}$(env_info)%{%F{magenta}%}%n%{%F{8}%}@%{%F{cyan}%}$(hostname -s)%{%f%} %{%B%F{blue}%}${PWD/#$HOME/~}%{%f%b%}$(jj_info)$(git_info)%{%f%} %(?,,%{${%B%F{white}%}[%?]%{%f%b%} )%% ' } |