aboutsummaryrefslogtreecommitdiff
path: root/zsh
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2025-12-02 10:21:48 +0100
committerRuben Beltran del Rio <jj@r.bdr.sh>2025-12-02 10:31:35 +0100
commitc06f19a29268059b9ef24c3206bed0a893aef44e (patch)
tree9dac3237d20c421174766dc1884b4d899cb85aef /zsh
parent2187a08bd3ec76dc4d9c008331493be699e6ab00 (diff)
parent8ce1b3d47f914811c289f06b8de43f7880125429 (diff)
Add jj status when available
Diffstat (limited to 'zsh')
-rw-r--r--zsh/functions/status.zsh41
-rw-r--r--zsh/modules/prompt.zsh2
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%} )%% '
}