blob: 82544f0e03c45d3dd37608964ac77b15b74235e2 (
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
|
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=`cat "$(tool_versions)" | rg rust | cut -d ' ' -f 2`
rustinfo=${ASDF_RUST_VERSION:-$rustinfo}
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 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)'
}
|