-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
94 lines (75 loc) · 3.04 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Display direnv output before instant prompt
eval "$(direnv export zsh)"
# ===================================================
# Theme
# ===================================================
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
. "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# zsh theme
# https://github.com/romkatv/powerlevel10k#manual
. $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || . ~/.p10k.zsh
# colorize ls
export CLICOLOR=1
# man page colors
export LESS_TERMCAP_mb=$(print -P "%F{cyan}") \
LESS_TERMCAP_md=$(print -P "%B%F{red}") \
LESS_TERMCAP_me=$(print -P "%f%b") \
LESS_TERMCAP_so=$(print -P "%K{magenta}") \
LESS_TERMCAP_se=$(print -P "%K{black}") \
LESS_TERMCAP_us=$(print -P "%U%F{green}") \
LESS_TERMCAP_ue=$(print -P "%f%u")
export PS1="%# "
# ===================================================
# Editors
# ===================================================
export EDITOR="subl -w"
export REACT_EDITOR=code
# ===================================================
# Keyboard settings
# ===================================================
# Don't eat the space before a pipe after tab completion
ZLE_SPACE_SUFFIX_CHARS=$'&|'
# ===================================================
# Tools and tab completions
# ===================================================
autoload -U bashcompinit && bashcompinit # Enable bash complete command
autoload -U compinit && compinit -i
# Enable autocompletion for aws cli
complete -C '$(brew --prefix)/bin/aws_completer' aws
# https://iterm2.com/documentation-shell-integration.html
export ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX=YES
. ~/.iterm2_shell_integration.zsh
# https://github.com/nvm-sh/nvm#install--update-script
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Automatically call nvm use
# https://github.com/nvm-sh/nvm#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file
autoload -U add-zsh-hook
load-nvmrc() {
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" != "$(nvm version)" ]; then
nvm use
fi
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc
if [[ -r ~/.aliasrc ]]; then
. ~/.aliasrc
fi
# https://direnv.net/docs/hook.html
eval "$(direnv hook zsh)"