-
Notifications
You must be signed in to change notification settings - Fork 4
/
dot_zshrc.tmpl
144 lines (120 loc) · 4.94 KB
/
dot_zshrc.tmpl
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# 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
# source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
# fi
[[ -d /opt/homebrew/bin ]] && eval "$(/opt/homebrew/bin/brew shellenv)"
[[ -d /home/linuxbrew/.linuxbrew/bin ]] && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# from homebrew, for completions
if [[ -d /opt/homebrew/share/zsh ]]; then
FPATH=/opt/homebrew/share/zsh/site-functions:$FPATH
fi
if [[ -d /usr/local/share/zsh ]]; then
FPATH=/usr/local/share/zsh/site-functions:$FPATH
fi
if [[ "$(uname)" = "Linux" ]]; then
export LINUX=1
fi
export HOMEBREW_INSTALL_FROM_API=1
# zsh settings
setopt pushd_ignore_dups # don't push the same directory twice
setopt extendedglob # Treat the ‘#’, ‘~’ and ‘^’ characters as part of patterns for filename generation, etc.
setopt nomatch # If a pattern for filename generation has no matches, print an error,
setopt notify # Report the status of background jobs immediately
unsetopt autocd # don't want
HISTFILE=~/.histfile
HISTSIZE=5000
SAVEHIST=50000
setopt append_history # append, not rewrite
setopt extended_history # timestamps too
setopt hist_ignore_dups # ignore immediate duplicates
setopt hist_ignore_all_dups # ignore all of 'em, too
# these three are mutually exclusive:
# setopt inc_append_history # append immediately
setopt inc_append_history_time # append after elapsed
# setopt share_history # share history, read immediately
# -i case ignore | -M more verbose prompting | -R raw control chars
# -X don't reinit term | -F quit if less than one screen | -x4 tabstop of 4
export LESS='-MRXFx4'
if [[ -n $(command -v /usr/libexec/java_home) ]] && /usr/libexec/java_home >/dev/null 2>&1; then
export JAVA_HOME=$(/usr/libexec/java_home)
elif [[ -L /opt/homebrew/opt/openjdk ]]; then
# export JAVA_HOME=/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home
export PATH=/opt/homebrew/opt/openjdk/bin:$PATH
fi
# colorized grep
# export GREP_OPTIONS='--color=auto'
# export GREP_COLOR='1;33'
# edit like vim, mostly
bindkey -v
bindkey '^A' beginning-of-line
bindkey '^E' end-of-line
bindkey -M viins '^Y' yank
bindkey -M viins '^U' kill-whole-line
# prompt settings
{{ if .linux }}
function set_window_title(){
print -Pn "\e]1;%~\a" # tab
print -Pn "\e]2;%n@%m: %~\a" # window
}
{{ else }}
function set_window_title(){
print -Pn "\e]1;%n@%m: %~\a" # tab
print -Pn "\e]2;%n@%m: %~\a" # window
}
{{ end }}
precmd_functions+=(set_window_title)
# # completions
zstyle :compinstall filename '/Users/nathan/.zshrc'
# # case-insensitive if there's no match
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
autoload -Uz compinit
compinit
# plugins
[[ -f /opt/homebrew/share/antigen/antigen.zsh ]] && source /opt/homebrew/share/antigen/antigen.zsh
[[ -f ~/.local/bin/antigen.zsh ]] && source ~/.local/bin/antigen.zsh
if [[ -n $(command -v antigen) ]]; then
antigen bundle Aloxaf/fzf-tab
antigen theme romkatv/powerlevel10k
antigen apply
else
echo "antigen is broken, skipping"
fi
# mac:
[[ -f /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] &&
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# linux
[[ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] &&
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# disable sort when completing `git checkout`
zstyle ':completion:*:git-checkout:*' sort false
# set descriptions format to enable group support
zstyle ':completion:*:descriptions' format '[%d]'
# set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# preview directory's content with exa when completing cd
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
# switch group using `,` and `.`
zstyle ':fzf-tab:*' switch-group ',' '.'
# Prompt not showing in Terminal and iTerm after upgrading to MacOS Catalina
# https://github.com/romkatv/powerlevel10k/issues/379
# https://gist.github.com/tombigel/d503800a282fcadbee14b537735d202c
# still TODO: set these limits in launchctl too
{{ if .mac }}
ulimit -n 200000
ulimit -u 2048
{{ end }}
source ~/.paths.sh
source ~/.utils.sh
source ~/.secrets.sh
source ~/.p10k.zsh # p10k prompt settings
[[ -f ~/.local.sh ]] && source ~/.local.sh # host-specific settings/aliases
[[ -f ~/.config/fzf/fzf.zsh ]] && source ~/.config/fzf/fzf.zsh
[[ -f ~/.local/bin/iterm2_shell_integration.zsh ]] && source ~/.local/bin/iterm2_shell_integration.zsh
if type direnv &>/dev/null; then
eval "$(direnv hook zsh)"
fi
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