-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzshrc_scd
35 lines (31 loc) · 1.12 KB
/
zshrc_scd
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
## Load scd function and its completion helper according to repository layout.
## Keep zsh-completion in fpath in case compinit is called after this script.
if [[ ${+functions[scd]} == 1 ]]; then
: "do nothing because scd is already defined."
else
_zshrc_scd_fpath=( $fpath )
_zshrc_scd_basedir=${${(%):-%x}:A:h:h}
fpath=( ${_zshrc_scd_basedir}/bin
${_zshrc_scd_basedir}/zsh-completion
$fpath )
autoload -Uz +X scd
if [[ ${+functions[compdef]} == 1 ]]; then
autoload -Uz +X _scd
compdef _scd scd
fi
fpath=( $_zshrc_scd_fpath ${_zshrc_scd_basedir}/zsh-completion )
unset -m "_zshrc_scd_*"
fi
## If the scd function exists, define a change-directory-hook function
## to record visited directories in the scd index.
if [[ ${+functions[scd]} == 1 ]]; then
chpwd_scd() { (( ZSH_SUBSHELL )) || scd --add $PWD }
autoload -Uz add-zsh-hook
add-zsh-hook chpwd chpwd_scd
else
print -u2 "scd could not be found neither in FPATH nor in PATH."
fi
## Load the directory aliases created by scd if any.
if [[ -s ~/.scdalias.zsh ]]; then
source ~/.scdalias.zsh
fi