-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path40-hooks.zsh
More file actions
49 lines (41 loc) · 1.04 KB
/
Copy path40-hooks.zsh
File metadata and controls
49 lines (41 loc) · 1.04 KB
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
# FIX: make neovim not crash instead of adding workarounds
if [[ ${PROBABLY_IN_LXC} -eq 1 ]]; then
function _set_title() {
:
}
else
function _set_title() {
# setting the title inside neovim crashes it
[[ -z ${NVIM} ]] && echo -ne "\033]0;$*\007"
}
fi
function _title_precmd_hook() {
_set_title "$(_current_dir) - ZSH"
}
function _title_preexec_hook() {
# abusing xargs to trim whitespace
_set_title "$(echo "${2}" | xargs) - ($(_current_dir)) - ZSH"
}
for name in precmd preexec; do
eval typeset -a "${name}_functions"
eval "${name}_functions"+=\("_title_${name}_hook"\)
done
_chpwd() {
if zle && [[ $#BUFFER -ne 0 ]]; then
zle .accept-line
return
fi
if [[ -z "${NO_AUTO_LS}" ]]; then
ls --color=auto -aFh
echo
fi
if [[ -z "${NO_AUTO_VCS_STATUS}" ]]; then
jj --no-pager status 2> /dev/null || git status 2> /dev/null
fi
if zle; then
echo
zle redisplay
fi
}
chpwd_functions+=(_chpwd)
zle -N accept-line _chpwd