-
Notifications
You must be signed in to change notification settings - Fork 0
/
prompt
52 lines (44 loc) · 1.6 KB
/
prompt
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
#!/bin/zsh
###################
# Vi mode indicator
function zle-line-init zle-keymap-select {
VIM_PROMPT="%{$fg_bold[yellow]%}[% NORMAL]% %{$reset_color%}"
RPS1="${${KEYMAP/vicmd/$VIM_PROMPT}/(main|viins)/}"
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
###################
autoload -U colors && colors
setopt promptsubst
git_br() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref=$(git rev-parse --short HEAD 2> /dev/null) || return
if [[ -n $(git status -s 2> /dev/null) ]]
then
echo "%{$fg[magenta]%}${ref#refs/heads/}%{$reset_color%} "
else
echo "%{$fg[green]%}${ref#refs/heads/}%{$reset_color%} "
fi
}
# local default_emoji='🐨'
# local emoji=${PROMPT_EMOJI:-$default_emoji}
# local user='%{$fg[green]%}%n%{$reset_color%}'
local username=$USER[0,5]
local user='%{$fg[green]%}${username}%{$reset_color%}'
# local host='%{$fg[green]%}%m%{$reset_color%}'
hn=$(hostname)
# hn=$(scutil --get ComputerName | tr '[:upper:]' '[:lower:]')
local hostname=$hn[0,3]
# local host='%{$fg[green]%}${hostname}%{$reset_color%}'
local gitbr='$(git_br)'
if [[ "${hn:(-5):5}" == 'local' || "${hn:(-3)}" == 'lan' || "${hn:(-5)}" == 'mynet' ]]; then
local pwd='%{$fg[blue]%}%c%{$reset_color%}'
local last_cmd_status='%(?.%{$fg[blue]%}.%{$fg[red]%})○%{$reset_color%}'
else
local pwd='%{$fg[green]%}%c%{$reset_color%}'
local last_cmd_status='%(?.%{$fg[green]%}.%{$fg[red]%})○%{$reset_color%}'
fi
# # With current time
# PROMPT="${pwd} ${gitbr}%{$fg[blue]%}%*%{$reset_color%} ${last_cmd_status} "
# PROMPT="${emoji} ${pwd} ${gitbr}${last_cmd_status} "
PROMPT="${pwd} ${gitbr}${last_cmd_status} "