-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzshrc.symlink
259 lines (209 loc) · 7.92 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# 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
export ZSH=$DOTFILES/zsh
source /usr/local/opt/powerlevel10k/share/powerlevel10k/powerlevel10k.zsh-theme
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
# define the code directory
# This is where my code exists and where I want the `c` autocomplete to work from exclusively
if [[ -d ~/code ]]; then
export CODE_DIR=~/code
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
# 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
# Tmux script hotkeys
# Find/open a new tmux session from select folders
bindkey -s ^f "~/.local/bin/tmux-sessionizer\n"
# 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"
plugins=(
fzf
ansible
)
if [[ -x "$(command -v fnm)" ]]; then
eval "$(fnm env --use-on-cd)"
fi
[[ -e ~/.terminfo ]] && export TERMINFO_DIRS=~/.terminfo:/usr/share/terminfo
########################################################
# Setup
########################################################
# language settings
export LANG=en_US.UTF-8
# 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
# fe [FUZZY PATTERN] - Open the selected file with the default editor
# - Bypass fuzzy finder if there's only one match (--select-1)
# - Exit if there's no match (--exit-0)
fe() {
local files
IFS=$'\n' files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
[[ -n "$files" ]] && ${EDITOR:-nvim} "${files[@]}"
}
# using ripgrep combined with preview
# find-in-file - usage: fif <searchTerm> <directory>
fif() {
if [ ! "$#" -gt 1 ]; then echo "Need a string to search for!"; return 1; fi
rg --files-with-matches --no-messages $1 | fzf --preview "highlight -O ansi -l {} 2> /dev/null | rg --colors 'match:bg:yellow' --ignore-case --pretty --context 10 $1 || rg --ignore-case --pretty --context 10 $1 {}"
[[ -n "$files" ]] && ${EDITOR:-nvim} "${files[@]}"
}
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 .....="cd ../../../.."
alias e="eza -la ${colorflag}"
alias eT="eza -laT ${colorflag}"
alias l="eza -la ${colorflag}"
alias lt="eza -laT ${colorflag}"
alias T="eza -T"
alias l="eza -la --blocks size:human ${colorflag}"
alias la="eza -a --classify ${colorflag}"
alias ll="eza -l --classify --blocks size:human ${colorflag}"
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
alias brewuuc="brew update && brew upgrade && brew cleanup" # update upgrade clean brew
alias ohmyzsh="vim ~/.oh-my-zsh"
alias vzsh="vim ~/.zshrc"
alias szsh="source ~/.zshrc"
# 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 {} +"
# tmux aliases
alias ta='tmux attach'
alias tls='tmux ls'
alias tat='tmux attach -t'
alias tns='tmux new-session -s'
alias tks='tmux kill-server'
alias lpath='echo $PATH | tr ":" "\n"' # list the PATH separated by new lines
alias nr="npm run"
# garden variety aliases - user specific
alias github='cd ~/github'
alias blog='cd ~/github/azemetredotcom'
alias playground='cd ~/playground'
alias personal='cd ~/personal'
alias learning='cd ~/learning'
alias learn='cd ~/learning'
alias dotfiles='cd ~/github/dotfiles'
alias dot='cd ~/github/dotfiles'
alias ideas='vim ~/azemetre-docs/projects-todo.md'
alias idea='vim ~/azemetre-docs/projects-todo.md'
alias docs='cd ~/azemetre-docs/'
source "$DOTFILES/zsh/utils.zsh"
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
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
. /usr/local/opt/asdf/libexec/asdf.sh
# Language PATHS
export PATH=$PATH:$(go env GOPATH)/bin