This repository was archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompt_frlo_setup
91 lines (76 loc) · 3.18 KB
/
prompt_frlo_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
79
80
81
82
83
84
85
86
87
88
89
90
#
# A simple theme that displays relevant, contextual information.
#
# Authors:
# Matthew Fiorillo <fiorillo@cmu.edu>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Screenshots:
# http://i.imgur.com/nBEEZ.png
#
# Load dependencies.
pmodload 'helper'
function prompt_frlo_host_colors {
# overcomplicated 3-digit hash:
array=(`print -P '121%M' | od -A n -t u4`)
url_hash=`printf '%03d' $(( (( ${(j:+:)array} )) % 1000 ))`
# overcomplicated way of choosing colors:
colors=('cyan' 'yellow' 'red' 'blue' 'green' 'cyan' 'yellow' 'red' 'blue' 'green')
color_a=`echo $url_hash | cut -c 1`+1
color_b=`echo $url_hash | cut -c 2`+1
color_c=`echo $url_hash | cut -c 3`+1
echo " %b%F{$colors[$color_a]}❯%F{$colors[$color_b]}❯%F{$colors[$color_c]}❯"
}
function prompt_frlo_pwd {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
_prompt_frlo_pwd="$MATCH"
unset MATCH
else
_prompt_frlo_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}"
fi
}
function prompt_frlo_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Format PWD.
prompt_frlo_pwd
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
fi
}
function prompt_frlo_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
# Load required functions.
autoload -Uz add-zsh-hook
# Add hook for calling git-info before each command.
add-zsh-hook precmd prompt_frlo_precmd
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
zstyle ':prezto:module:editor:info:keymap:primary' format `prompt_frlo_host_colors`
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{green}❮%F{yellow}❮%F{red}❮%f%b'
zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b'
zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b'
zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b'
zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b'
zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f'
zstyle ':prezto:module:git:info:commit' format ':%F{green}%.7c%f'
zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b'
zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b'
zstyle ':prezto:module:git:info:position' format ':%F{red}%p%f'
zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b'
zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b'
zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b'
zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b'
zstyle ':prezto:module:git:info:keys' format \
'prompt' ' %F{blue}git%f$(coalesce "%b" "%p" "%c")%s' \
'rprompt' '%A%B%S%a%d%m%r%U%u'
# Define prompts.
PROMPT='%F{cyan}${_prompt_frlo_pwd}%f${git_info:+${(e)git_info[prompt]}}%(!. %B%F{red}#%f%b.) ${editor_info[keymap]} '
RPROMPT='${editor_info[overwrite]}%(?:: %F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_info[rprompt]}'
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
}
prompt_frlo_setup "$@"