]> git.r.bdr.sh - rbdr/dotfiles/blame - zsh/functions/status.zsh
Update deps, fix for linux
[rbdr/dotfiles] / zsh / functions / status.zsh
CommitLineData
b6bcca60
RBR
1function tool_versions() {
2 if [[ -s ".tool-versions" ]]; then
3 echo '.tool-versions'
4 return
5 fi
6 echo "${HOME}/.tool-versions"
7}
8
9function env_info_provider() { echo "%{%F{green}%}n/a"; }
10function env_info {
11 echo "[%{%F{cyan}%}ENV%{%F{black}%} $(env_info_provider)%{%F{black}%}]"
12}
13
14function python_info {
15 pythoninfo=`cat "$(tool_versions)" | rg python | cut -d ' ' -f 2`
16 pythoninfo=${ASDF_PYTHON_VERSION:-$pythoninfo}
17 venv="${VIRTUAL_ENV##*/}"
18 echo "%{%F{green}%}py%{%F{black}%} ${pythoninfo:-no}@${venv:-default}"
19}
20
21function rust_info {
22 rustinfo=`cat "$(tool_versions)" | rg rust | cut -d ' ' -f 2`
23 rustinfo=${ASDF_RUST_VERSION:-$rustinfo}
24 echo "%{%F{red}%}rs%{%F{black}%} ${rustinfo:-no}"
25}
26
27function node_info {
28 nodeinfo=`cat "$(tool_versions)" | rg nodejs | cut -d ' ' -f 2`
29 nodeinfo=${ASDF_NODEJS_VERSION:-$nodeinfo}
30 echo "%{%F{yellow}%}js%{%F{black}%} ${nodeinfo:-no}"
31}
32
33function git_info {
34 branch=$(git branch --show-current 2> /dev/null)
35
36 if [ ! -z $branch ]; then
37 echo -n "@%F{cyan}$branch%f"
38
39 status_output=$(git status --short)
40
41 if echo "$status_output" | rg -q '^??'; then
42 echo -n "%{%F{magenta}%}?%f"
43 fi
44
45 if echo "$status_output" | rg -q '^ M'; then
46 echo -n "%{%F{magenta}%}!%f"
47 fi
48
49 if echo "$status_output" | rg -q '^ D'; then
50 echo -n "%{%F{magenta}%}×%f"
51 fi
52
53 if echo "$status_output" | rg -q '^A '; then
54 echo -n "%{%F{green}%}+%f"
55 fi
56 fi
57}
58
59function status {
7af82a55 60 print -P '%{%F{black}%}$(env_info) $(node_info) $(rust_info) $(python_info)'
b6bcca60 61}