diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-02 10:21:48 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-02 10:31:35 +0100 |
| commit | c06f19a29268059b9ef24c3206bed0a893aef44e (patch) | |
| tree | 9dac3237d20c421174766dc1884b4d899cb85aef /zsh/functions | |
| parent | 2187a08bd3ec76dc4d9c008331493be699e6ab00 (diff) | |
| parent | 8ce1b3d47f914811c289f06b8de43f7880125429 (diff) | |
Add jj status when available
Diffstat (limited to 'zsh/functions')
| -rw-r--r-- | zsh/functions/status.zsh | 41 |
1 files changed, 40 insertions, 1 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) |