-
Notifications
You must be signed in to change notification settings - Fork 8
/
prompt_clean_setup
78 lines (66 loc) · 2.3 KB
/
prompt_clean_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
#!/bin/env zsh
source $^fpath/prompt_framework(N)
prompt_clean_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='3'
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
if [[ $term -eq 0 ]]; then
ps1=(
$prompt_newline # Initial newline, for spaciousness.
$prompt_username
'%F{45}%5v%f' # Path
'%(1V. %F{%(3V.83.242)}%1v%2v%(3V. %3v.)%f.)' # VCS status
'%(4V. %F{215}%4v%f.)' # Execution time
$prompt_newline # Separate preprompt and prompt.
"%F{%(?.207.203)}%(!.$root_prompt_sym.$prompt_sym)%f " # Prompt symbol
)
PS2="%F{242}%_ %F{37}%(!.#.$prompt_sym)%f "
else
ps1=(
$prompt_newline # Initial newline, for spaciousness.
$prompt_username
'%F{14}%5v%f' # Path
'%(1V. %F{%(3V.10.8)}%1v%2v%(3V. %3v.)%f.)' # VCS status
'%(4V. %F{11}%4v%f.)' # Execution time
$prompt_newline # Separate preprompt and prompt.
"%F{%(?.13.9)}%(!.$root_prompt_sym.$prompt_sym)%f " # Prompt symbol
)
PS2="%F{8}%_ %F{14}%(!.#.$prompt_sym)%f "
fi
PS1="${(j..)ps1}"
}
prompt_clean_preview () {
prompt_preview_theme clean
prompt_preview_theme clean 256color
prompt_preview_theme clean xterm 0
prompt_preview_theme clean 256color 0
}
prompt_clean_setup "$@"