-
Notifications
You must be signed in to change notification settings - Fork 8
/
prompt_inline_setup
79 lines (67 loc) · 2.14 KB
/
prompt_inline_setup
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
#!/bin/env zsh
source $^fpath/prompt_framework(N)
prompt_inline_setup() {
setopt localoptions noshwordsplit prompt_subst
# Load required modules
zmodload zsh/datetime
zmodload zsh/parameter
unset PS1 PS2 RPS1
prompt_clean_zstyles
prompt_clean_add_hooks
if [[ -n $2 ]]; then
prompt_clean_pwd_length=$2
else
prompt_clean_pwd_length='1'
fi
local prompt_sym root_prompt_sym prompt_username term
zstyle -s ':clean:normal:render' prompt-symbol prompt_sym || prompt_sym='❯'
zstyle -s ':clean:root:render' prompt-symbol root_prompt_sym || root_prompt_sym='#'
if [[ -n $1 ]]; then
[[ $1 =~ '256color$' ]]; term=$?
else
[[ $TERM =~ '256color$' ]]; term=$?
fi
# show username@host if logged in through SSH
if [[ $SSH_CONNECTION != '' ]]; then
if [[ $term -eq 0 ]]; then
prompt_username='%F{83}%m%f:'
else
prompt_username='%F{10}%m%f:'
fi
fi
# ( which rvm-prompt &> /dev/null ) && rvm_prompt='%F{242}$(rvm-prompt)%f'
# Construct the new prompt with a clean preprompt.
local -ah ps1 rps1
if [[ $term -eq 0 ]]; then
ps1=(
$prompt_username
'%F{45}%5v%f ' # Path
"%F{%(?.207.203)}%(!.$root_prompt_sym.$prompt_sym)%f " # Prompt symbol
)
rps1=(
'%(4V.%F{215}%4v%f .)' # Execution time
'%(1V.%F{%(3V.83.242)}%1v%2v%(3V. %3v.)%f.)' # VCS status
)
PS2="%F{242}%_ %F{37}%(!.#.$prompt_sym)%f "
else
ps1=(
$prompt_username
'%F{14}%5v%f ' # Path
"%F{%(?.13.9)}%(!.$root_prompt_sym.$prompt_sym)%f " # Prompt symbol
)
rps1=(
'%(4V.%F{11}%4v%f .)' # Execution time
'%(1V.%F{%(3V.10.8)}%1v%2v%(3V. %3v.)%f.)' # VCS status
)
PS2="%F{8}%_ %F{14}%(!.#.$prompt_sym)%f "
fi
PS1="${(j..)ps1}"
RPS1="${(j..)rps1}"
}
prompt_inline_preview () {
prompt_preview_theme inline
prompt_preview_theme inline 256color
prompt_preview_theme inline xterm 0
prompt_preview_theme inline 256color 0
}
prompt_inline_setup "$@"