blob: 9b41e320f863d249249e38d3d71a28d1484ba71a (
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
|
autoload -Uz promptinit && promptinit
if [[ "$TERM" == (dumb|linux|*bsd*) ]] || (( $#prompt_argv < 1 )); then
prompt 'off'
fi
#
# ZLE widgets
#
function zle-line-init zle-keymap-select {
# Couldn't figure out how to get tmux and iTerm to agree on how to render
# these characters... so there you go.
local normal_symbol="N"
local insert_symbol="I"
local error_symbol="X"
# Show vi status / return status on the right side
local return_status="%{%F{red}%}%(?.. $error_symbol)%{$reset_color%}"
if [ $KEYMAP = 'vicmd' ]; then
local edit_status="%{%F{cyan}%}$normal_symbol"
else
local edit_status="%{%F{green}%}$insert_symbol"
fi
RPROMPT="${edit_status}${return_status}%{$reset_color%}"
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
#
# Setup Prompt
#
function prompt_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
# Load required functions.
autoload -Uz add-zsh-hook
# Define prompts.
PROMPT='
%{%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%} )%% '
}
prompt_setup "$@"
setopt PROMPT_SUBST
setopt PROMPT_PERCENT
setopt TRANSIENT_RPROMPT
|