]> git.r.bdr.sh - rbdr/dotfiles/blob - zsh/modules/prompt.zsh
Merge branch 'main' of git.sr.ht:~rbdr/dotfiles
[rbdr/dotfiles] / zsh / modules / prompt.zsh
1 autoload -Uz promptinit && promptinit
2
3 if [[ "$TERM" == (dumb|linux|*bsd*) ]] || (( $#prompt_argv < 1 )); then
4 prompt 'off'
5 fi
6
7 #
8 # ZLE widgets
9 #
10
11 function zle-line-init zle-keymap-select {
12
13 # Couldn't figure out how to get tmux and iTerm to agree on how to render
14 # these characters... so there you go.
15
16 local normal_symbol="N"
17 local insert_symbol="I"
18 local error_symbol="X"
19
20 # Show vi status / return status on the right side
21
22 local return_status="%{%F{red}%}%(?.. $error_symbol)%{$reset_color%}"
23 if [ $KEYMAP = 'vicmd' ]; then
24 local edit_status="%{%F{cyan}%}$normal_symbol"
25 else
26 local edit_status="%{%F{green}%}$insert_symbol"
27 fi
28
29 RPROMPT="${edit_status}${return_status}%{$reset_color%}"
30 zle reset-prompt
31 }
32 zle -N zle-line-init
33 zle -N zle-keymap-select
34
35 #
36 # Setup Prompt
37 #
38
39 function prompt_setup {
40 setopt LOCAL_OPTIONS
41 unsetopt XTRACE KSH_ARRAYS
42 prompt_opts=(cr percent subst)
43
44 # Load required functions.
45 autoload -Uz add-zsh-hook
46
47 # Define prompts.
48 PROMPT='
49 %{%F{black}%}$(env_info) $(node_info) $(rust_info) $(python_info)
50 %{%F{magenta}%}%n%{%f%}@%{%F{yellow}%}$(hostname -s)%{%f%} %{%B%F{green}%}${PWD/#$HOME/~}%{%f%b%}$(git_info)%{%f%}
51 %(?,,%{${%B%F{white}%}[%?]%{%f%b%} )%% '
52 }
53
54 prompt_setup "$@"
55 setopt PROMPT_SUBST
56 setopt PROMPT_PERCENT
57 setopt TRANSIENT_RPROMPT