forked from nicknisi/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc.symlink
230 lines (185 loc) · 7.09 KB
/
zshrc.symlink
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
export ZSH=$DOTFILES/zsh
if [[ -d $DOTFILES/zsh/functions ]]; then
for func in $DOTFILES/zsh/functions/*(:t); autoload -U $func
fi
########################################################
# Configuration
########################################################
COLOR_BLACK="\e[0;30m"
COLOR_BLUE="\e[0;34m"
COLOR_GREEN="\e[0;32m"
COLOR_CYAN="\e[0;36m"
COLOR_PINK="\e[0;35m"
COLOR_RED="\e[0;31m"
COLOR_PURPLE="\e[0;35m"
COLOR_BROWN="\e[0;33m"
COLOR_LIGHTGRAY="\e[0;37m"
COLOR_DARKGRAY="\e[1;30m"
COLOR_LIGHTBLUE="\e[1;34m"
COLOR_LIGHTGREEN="\e[1;32m"
COLOR_LIGHTCYAN="\e[1;36m"
COLOR_LIGHTRED="\e[1;31m"
COLOR_LIGHTPURPLE="\e[1;35m"
COLOR_YELLOW="\e[1;33m"
COLOR_WHITE="\e[1;37m"
COLOR_NONE="\e[0m"
if [ -z "$TMUX" ]; then
export TERM=xterm-256color-italic
else
export TERM=tmux-256color
fi
# initialize autocomplete
autoload -U compinit add-zsh-hook
compinit
# prepend_path $HOME/npmbin/node_modules/.bin
prepend_path /usr/local/opt/grep/libexec/gnubin
prepend_path /usr/local/sbin
prepend_path $DOTFILES/bin
prepend_path $HOME/bin
# Initialize pyenv
[[ -n "$(command -v pyenv)" ]] && eval "$(pyenv init -)"
# define the code directory
# This is where my code exists and where I want the `c` autocomplete to work from exclusively
if [[ -d ~/Dev ]]; then
export CODE_DIR=~/Dev
fi
# display how long all tasks over 10 seconds take
export REPORTTIME=10
export KEYTIMEOUT=1 # 10ms delay for key sequences
setopt NO_BG_NICE
setopt NO_HUP # don't kill background jobs when the shell exits
setopt NO_LIST_BEEP
setopt LOCAL_OPTIONS
setopt LOCAL_TRAPS
setopt PROMPT_SUBST
# history
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt EXTENDED_HISTORY # write the history file in the ":start:elapsed;command" format.
setopt HIST_REDUCE_BLANKS # remove superfluous blanks before recording entry.
setopt SHARE_HISTORY # share history between all sessions.
setopt HIST_IGNORE_ALL_DUPS # delete old recorded entry if new entry is a duplicate.
setopt COMPLETE_ALIASES
# make terminal command navigation sane again
bindkey "^[[1;5C" forward-word # [Ctrl-right] - forward one word
bindkey "^[[1;5D" backward-word # [Ctrl-left] - backward one word
bindkey '^[^[[C' forward-word # [Ctrl-right] - forward one word
bindkey '^[^[[D' backward-word # [Ctrl-left] - backward one word
bindkey '^[[1;3D' beginning-of-line # [Alt-left] - beginning of line
bindkey '^[[1;3C' end-of-line # [Alt-right] - end of line
bindkey '^[[5D' beginning-of-line # [Alt-left] - beginning of line
bindkey '^[[5C' end-of-line # [Alt-right] - end of line
bindkey '^?' backward-delete-char # [Backspace] - delete backward
if [[ "${terminfo[kdch1]}" != "" ]]; then
bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
else
bindkey "^[[3~" delete-char # [Delete] - delete forward
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
fi
bindkey "^A" vi-beginning-of-line
bindkey -M viins "^F" vi-forward-word # [Ctrl-f] - move to next word
bindkey -M viins "^E" vi-add-eol # [Ctrl-e] - move to end of line
bindkey "^J" history-beginning-search-forward
bindkey "^K" history-beginning-search-backward
# matches case insensitive for lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# pasting with tabs doesn't perform completion
zstyle ':completion:*' insert-tab pending
# default to file completion
zstyle ':completion:*' completer _expand _complete _files _correct _approximate
########################################################
# Plugin setup
########################################################
export ZPLUGDIR="$CACHEDIR/zsh/plugins"
[[ -d "$ZPLUGDIR" ]] || mkdir -p "$ZPLUGDIR"
# array containing plugin information (managed by zfetch)
typeset -A plugins
zfetch mafredri/zsh-async async.plugin.zsh
zfetch zsh-users/zsh-syntax-highlighting
zfetch zsh-users/zsh-autosuggestions
zfetch chriskempson/base16-shell
zfetch Aloxaf/fzf-tab
if [[ -x "$(command -v fnm)" ]]; then
eval "$(fnm env --use-on-cd)"
fi
[[ -e ~/.terminfo ]] && export TERMINFO_DIRS=~/.terminfo:/usr/share/terminfo
########################################################
# Setup
########################################################
# If a local zshrc exists, source it
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
if [[ -a ~/.localrc ]]; then
source ~/.localrc
fi
# add a config file for ripgrep
export RIPGREP_CONFIG_PATH="$HOME/.rgrc"
[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules}/*" 2> /dev/null'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# add color to man pages
export MANROFFOPT='-c'
export LESS_TERMCAP_mb=$(tput bold; tput setaf 2)
export LESS_TERMCAP_md=$(tput bold; tput setaf 6)
export LESS_TERMCAP_me=$(tput sgr0)
export LESS_TERMCAP_so=$(tput bold; tput setaf 3; tput setab 4)
export LESS_TERMCAP_se=$(tput rmso; tput sgr0)
export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7)
export LESS_TERMCAP_ue=$(tput rmul; tput sgr0)
export LESS_TERMCAP_mr=$(tput rev)
export LESS_TERMCAP_mh=$(tput dim)
# source z.sh if it exists
zpath="$(brew --prefix)/etc/profile.d/z.sh"
if [ -f "$zpath" ]; then
source "$zpath"
fi
########################################################
# Aliases
########################################################
# reload zsh config
alias reload!='RELOAD=1 source ~/.zshrc'
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # macOS `ls`
colorflag="-G"
fi
# use nvim, but don't make me think about it
[[ -n "$(command -v nvim)" ]] && alias vim="nvim"
# Filesystem aliases
alias ..='cd ..'
alias ...='cd ../..'
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias l="ls -lah ${colorflag}"
alias la="ls -AF ${colorflag}"
alias ll="ls -lFh ${colorflag}"
alias lld="ls -l | grep ^d"
alias rmf="rm -rf"
# Helpers
alias grep='grep --color=auto'
alias df='df -h' # disk free, in Gigabytes, not bytes
alias du='du -h -c' # calculate disk usage for a folder
# Applications
alias ios='open -a /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app'
# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# Recursively delete `.DS_Store` files
alias cleanup="find . -name '*.DS_Store' -type f -ls -delete"
# remove broken symlinks
alias clsym="find -L . -name . -o -type d -prune -o -type l -exec rm {} +"
# git aliases
alias gs='git s'
alias glog="git l"
# tmux aliases
alias ta='tmux attach'
alias tls='tmux ls'
alias tat='tmux attach -t'
alias tns='tmux new-session -s'
alias lpath='echo $PATH | tr ":" "\n"' # list the PATH separated by new lines
alias nr="npm run"
source "$DOTFILES/zsh/utils.zsh"
source "$DOTFILES/zsh/prompt.zsh"
eval "$(pyenv virtualenv-init -)"