-
Notifications
You must be signed in to change notification settings - Fork 8
/
zshrc
189 lines (152 loc) Β· 6.16 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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
## clear existing aliases
unalias -m '*'
## plugins
source ~/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source ~/.zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
## autoloading
autoload colors # color array builder
autoload run-help # help function
autoload zcalc # calculator
autoload zsh/terminfo # interface to terminfo database
autoload ~/.zsh/functions/* # autoload all functions in local functions directory
## completions
# add local completions directory to fpath
fpath=(~/.zsh/completions /opt/homebrew/share/zsh/site-functions $fpath)
zstyle ':completion:*:descriptions' format "%U%B%d%b%u"
zstyle ':completion:*:messages' format "%F{blue}%d%f"
autoload -Uz compinit
compinit -C -d ~/.zsh/compdump
## path
INITIAL_PATH_ELEMENTS=(${(s/:/)PATH}) # save initial path elements
PATH='' # clear path variable
path: ~/bin # artisanal binaries
path: ~/.fzf/bin # fzf
path: ~/.local/bin # pipx
path: ~/.local/bin/polaris # polaris binaries
path: ~/sbin # admin binaries
path: ~/.cargo/bin # cargo
path: ~/.vim/plugged/vim-superman/bin # vman script
path: ~/.nix-profile/bin # nix env binaries
path: ~/opt/npm/bin # npm binaries
path: /usr/local/bin # homebrew binaries
path: /usr/local/sbin # admin homebrew binaries
path: /usr/local/opt/bin # keg-only homebrew binaries
path: /opt/homebrew/bin # homebrew arm binaries
path: /opt/homebrew/sbin # admin homebrew arm binaries
path: /opt/local/bin # macports
path: /usr/bin # binaries
path: /usr/sbin # admin binaries
path: /usr/games # games
path: /bin # core binaries
path: /sbin # core admin binaries
path: ~/.local/share/solana/install/active_release/bin # solana binaries
# append initial path components
for PART in $INITIAL_PATH_ELEMENTS; do
path: $PART
done
## exported variables
unset MAILCHECK # don't check for mail
export BLOCKSIZE=K # show blocks as kilobytes
export CARGO_ASC=false # show errors in descending order
export CARGO_MSG_LIMIT=0 # show one message at a time
export CARGO_OPEN_WARN=true # populate quickfix list with warnings
export CLICOLOR=1 # use color
export EDITOR=vim # vim as editor
export EDMV_EDITOR=vim # vim as editor in edmv
export HISTFILE=~/.history # location for the history file
export HISTSIZE=5500000 # save lots of history in memory
export HOMEBREW_NO_AUTO_UPDATE=1 # don't automatically update packages
export HOMEBREW_NO_ENV_HINTS=1 # suppress homebrew hints
export KEYTIMEOUT=1 # don't wait for multibyte sequences
export LANG=en_US.UTF-8 # use the english utf-8 locale
export LESS=-ifRMx2 # default options for less
export LS_OPTIONS='--color=auto' # make ls use color
export PAGER=less # less as pager
export PIPENV_VENV_IN_PROJECT=enabled # put pipenv environments in project
export SAVEHIST=5000000 # save lots of history to disk
export VISUAL=vim # vim as visual editor
# set HOST variable
HOSTNAME=`hostname`
export HOST=${HOSTNAME%.local}
# tell ripgrep to use a config file
export RIPGREP_CONFIG_PATH=~/.ripgreprc
# use ripgrep with fzf
export FZF_DEFAULT_COMMAND="rg --files --hidden --glob '!.git/*' --glob '!*.pyc'"
# use fd for fzf-file-widget
export FZF_CTRL_T_COMMAND="fd --hidden --exclude '.git' --exclude '.git/*'"
## local variables
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=black,bold" # make autosuggestions grey
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20 # don't autosuggest when buffer is large
ZLE_REMOVE_SUFFIX_CHARS='' # don't remove spaces after completion
## options
unsetopt beep # never beep
unsetopt correct # don't correct command spelling
setopt auto_remove_slash # automatically remove slash from completions
setopt brace_ccl # expand expressions in braces
setopt hist_expire_dups_first # expire duplicate events first
setopt hist_find_no_dups # ignore duplicates in find
setopt hist_ignore_dups # dont save duplicate entries in history
setopt hist_ignore_space # do not save history entries that start with a space
setopt hist_no_functions # do not save function definitions in history
setopt inc_append_history # save commands in history immediately
setopt interactive_comments # allow comments in interactive shells
setopt multios # allow redirection to multiple files
setopt prompt_subst # expand the prompt string
setopt rc_quotes # allow '' to represent a quote in single quoted strings
setopt share_history # share history between shells
## tty
stty -ixoff # disable sending start/stop characters
stty -ixon # disable start/stop output control
stty start undef # unmap c-q
stty stop undef # unmap c-s
tabs -2 # use two space tabs
## ulimit
ulimit -n 1024 # increase maximum number of open files
## editing
# use vi keybindings
bindkey -v
# add custom bindings
bind: ' ' magic-space
bind: '\eK' kill-line-to-system-clipboard
bind: '\eY' yank-from-system-clipboard
bind: '\e^?' backward-kill-word
bind: '\eb' backward-word
bind: '\ef' forward-word
bind: '\ek' kill-line-to-system-clipboard
bind: '\ey' yank-from-system-clipboard
bind: '^?' backward-delete-char
bind: '^A' beginning-of-line
bind: '^B' backward-char
bind: '^E' end-of-line
bind: '^F' forward-char
bind: '^G' fzf-cd-widget
bind: '^H' backward-delete-char
bind: '^J' vi-cmd-mode
bind: '^K' kill-line-to-x-selection
bind: '^N' down-history
bind: '^P' up-history
bind: '^Q' exit-zsh
bind: '^R' history-incremental-search-backward
bind: '^S' history-incremental-search-forward
bind: '^T' fzf-file-widget
bind: '^U' kill-whole-line
bind: '^W' backward-kill-word
bind: '^X' fzf-history-widget
bind: '^Y' yank-from-x-selection
bind: '^Z' fzf-file-widget
bind: '^[[A' history-substring-search-up
bind: '^[[B' history-substring-search-down
zle -N exit-zsh # exit zsh
zle -N zle-keymap-select prompt-reset # redraw prompt when keymap changes
zle -N zle-line-init prompt-reset # redraw prompt on line editor start
## add aliases for all recipes in ~/.user.justfile
for recipe in `just --justfile ~/.user.justfile --summary 2> /dev/null`; do
alias $recipe="just --justfile ~/.user.justfile --working-directory . $recipe"
done
## config files
source: ~/.extrarc # extras
source: ~/.fzf.zsh # fzf bindings
source: ~/.zsh/aliases.zsh # aliases
source: ~/.zsh/clipboard.zsh # set up system keyboard integration
source: ~/.zsh/prompt.zsh # set up prompt
source: ~/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh