forked from mkjmdski/.dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
71 lines (57 loc) · 1.51 KB
/
.zshrc
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
export DOTFILES="$HOME/.dotfiles"
sources="$DOTFILES/zsh/sources"
source $sources/path.zsh
source $sources/spaceship.zsh
source ~/.zinit/bin/zinit.zsh
autoload -Uz compinit
compinit
zstyle ':completion:*' menu select
source $sources/zinit.zsh
source $sources/commands.zsh
if [[ -f "$HOME/repos/agmar/toolkitz/programs/.rc" ]]; then
source "$HOME/repos/agmar/toolkitz/programs/.rc"
fi
# auto change directory
setopt auto_cd
# use brace
setopt brace_ccl
# compacked complete list display
setopt list_packed
setopt auto_remove_slash
# resolve symlinks
setopt chase_links
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$node_version" ]; then
nvm use
fi
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
# what to do when change location
standard-chpwd() {
if [ -d ".git" ] || [ -f ".git" ]; then
if [ ! -f ".git/index.lock" ]; then
git pull &
fi
fi
if [ -d "venv" ] && [ -z "$VIRTUAL_ENV" ]; then
source venv/bin/activate
fi
if [ ! -d "venv" ] && [ ! -z "$VIRTUAL_ENV" ]; then
deactivate
fi
}
if [[ $commands[nvm] ]]; then
add-zsh-hook chpwd load-nvmrc
fi
add-zsh-hook chpwd standard-chpwd
load-nvmrc