blob: f7f38ce6e5b63dc867a8526d761ac7f71a54ae24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
function tool_versions() {
if [[ -s ".tool-versions" ]]; then
echo '.tool-versions'
return
fi
echo "${HOME}/.tool-versions"
}
function env_info_provider() { echo "%{%F{green}%}n/a"; }
function env_info {
echo "\u300c%{%F{black}%} $(env_info_provider)%{%F{black}%} \u300d"
}
function python_info {
pythoninfo=`cat "$(tool_versions)" | rg python | cut -d ' ' -f 2`
pythoninfo=${ASDF_PYTHON_VERSION:-$pythoninfo}
venv="${VIRTUAL_ENV##*/}"
echo "%{%F{green}%}py%{%F{black}%} ${pythoninfo:-no}@${venv:-default}"
}
function rust_info {
rustinfo=`rustup show profile`
echo "%{%F{red}%}rs%{%F{black}%} ${rustinfo:-no}"
}
function node_info {
nodeinfo=`cat "$(tool_versions)" | rg nodejs | cut -d ' ' -f 2`
nodeinfo=${ASDF_NODEJS_VERSION:-$nodeinfo}
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"
status_output=$(git status --short)
# Modified Files, Unstaged
if echo "$status_output" | rg -q '^ M'; then
echo -n "%{%F{magenta}%}△%f"
fi
# Modified Files, Staged
if echo "$status_output" | rg -q '^M'; then
echo -n "%{%F{green}%}△%f"
fi
# Untracked Files
if echo "$status_output" | rg -q '^\?\?'; then
echo -n "%{%F{magenta}%}+%f"
fi
# Added Files
if echo "$status_output" | rg -q '^A '; then
echo -n "%{%F{green}%}+%f"
fi
# Deleted Files, Unstaged
if echo "$status_output" | rg -q '^ D'; then
echo -n "%{%F{magenta}%}×%f"
fi
# Deleted Files, Staged
if echo "$status_output" | rg -q '^D'; then
echo -n "%{%F{green}%}×%f"
fi
echo -n "%f"
fi
}
function status {
print -P '%{%F{black}%}$(env_info) $(node_info) $(rust_info) $(python_info)'
}
|