forked from nicknisi/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc.symlink
376 lines (296 loc) · 11.4 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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# Uncomment to debug startup (and at the end of the file)
# Taken from https://blog.askesis.pl/post/2017/04/how-to-debug-zsh-startup-time.html
#zmodload zsh/zprof
export DOTFILES=$HOME/.dotfiles
export ZSH=$DOTFILES/zsh
# TODO: check https://dustri.org/b/my-zsh-configuration.html
# TODO check https://github.com/mika/zsh-pony
# Native ZSH feature: https://nuclearsquid.com/writings/reporttime-in-zsh/
# Report stats for task longer that XX seconds
export REPORTTIME=10
############################################
# Setup TERM
############################################
# [[ -e ~/.terminfo ]] && export TERMINFO_DIRS=~/.terminfo:/usr/share/terminfo
# if [ -z "$TMUX" ]; then
# export TERM=xterm-256color-italic
# else
# export TERM=tmux-256color-italic
# fi
############################################
# Key Bindings
############################################
# Set Emacs Mode
bindkey -e
# move to next word with ctrl-F
# bindkey -M viins "^F" vi-forward-word
# Move to end of line with ctrl-E
# bindkey -M viins "^E" vi-add-eol
# make terminal command navigation sane again
# bindkey '^[^[[D' backward-word
# bindkey '^[^[[C' forward-word
# bindkey '^[[5D' beginning-of-line
# bindkey '^[[5C' end-of-line
# bindkey '^[[3~' delete-char
# bindkey '^?' backward-delete-char
############################################
# Configure PROMPT
############################################
# Configure Prompt
# source "$ZSH/prompt.zsh"
setopt PROMPT_SUBST
# Reference: http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Prompt-Expansion
# username path >
export PROMPT="%B%F{cyan}%n %F{blue}%2~%b%#%f "
############################################
# Configure ZSH History
############################################
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
# history
setopt HIST_VERIFY
setopt HIST_REDUCE_BLANKS
setopt HIST_IGNORE_ALL_DUPS
setopt extended_history # record timestamp of command in HISTFILE
setopt sharehistory # Share history across terminals
setopt hist_ignore_space # ignore commands that start with space
############################################
# Other ZSH Options
############################################
# JOB Control Options
# -------------------
setopt NO_BG_NICE
setopt NO_HUP
# Zsh Function options
# -------------------
setopt NO_LIST_BEEP
# DISABLED SINCE ZPLUG ASSUMES OTHERWISE
# setopt LOCAL_OPTIONS
# If this option is set when a signal trap is set inside a function,
# then the previous status of the trap for that signal will be restored when the function exits
# setopt LOCAL_TRAPS
#setopt IGNORE_EOF
############################################
# ENV Variables
############################################
# OS X will use colors for LS with this
export CLICOLOR=true
export EDITOR='nvim'
export GIT_EDITOR='nvim'
# rigrep config
export RIPGREP_CONFIG_PATH="$HOME/.rgrc"
# GO Setup
export CODE_DIR="$HOME/Documents"
export GOROOT="/usr/local/go"
export GOPATH="$GOROOT/bin"
export PATH=$PATH:${GOPATH}
# Use go1.13 for now
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
# Android Setup
export ANDROID_HOME=/usr/local/share/android-sdk
export ANDROID_NDK=/usr/local/share/android-ndk
# export PATH=$PATH:$ANDROID_HOME/emulator
# export PATH=$PATH:$ANDROID_HOME/tools
# export PATH=$PATH:$ANDROID_HOME/tools/bin
# export PATH=$PATH:$ANDROID_HOME/platform-tools
# Default editor for debugging react
export REACT_EDITOR=code
# ENV Variables for colors
source "$ZSH/colors.zsh"
# LOCALE
export LC_ALL=en_US.UTF-8
############################################
# Run zsh child configs
############################################
# Define Aliases & Functions
source "$ZSH/aliases.zsh"
source "$ZSH/functions.zsh"
fpath=($ZSH/functions $fpath)
autoload -U $ZSH/functions/*(:t)
# Run local (not public git friendly) zsh file
if [[ -a ~/.localrc ]]; then
source ~/.localrc
fi
############################################
# Setup PATH basic directories
############################################
export PATH=/usr/local/bin:$PATH
# add /usr/local/sbin
if [[ -d /usr/local/sbin ]]; then
export PATH=/usr/local/sbin:$PATH
fi
# adding path directory for custom scripts
export PATH=$DOTFILES/bin:$PATH
# check for custom bin directory and add to path
if [[ -d ~/bin ]]; then
export PATH=~/bin:$PATH
fi
############################################
# Color For 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)
############################################
# Setup Homebrew install completions
############################################
# Snippet obtained from https://docs.brew.sh/Shell-Completion
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
fi
############################################
# Setup FZF
############################################
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_CTRL_T_COMMAND="fd --color=never"
export FZF_ALT_C_COMMAND="fd --color=never--type d"
############################################
# Setup Z
############################################
# Needs to happen before loading fz zplug plugin
zpath="$(brew --prefix)/etc/profile.d/z.sh"
[ -f "${zpath}" ] && source "${zpath}"
############################################
# ZPLUG Plugins
############################################
source "$ZSH/zplug.zsh"
############################################
# Setup hub
############################################
if command -v hub > /dev/null 2>&1; then
alias git=hub
fi
############################################
# Setup Google Cloud SDK
############################################
if command -v gcloud > /dev/null 2>&1; then
# Obtained from `brew cask info google-cloud-sdk`
local gcloud_path="/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
source "${gcloud_path}/path.zsh.inc"
source "${gcloud_path}/completion.zsh.inc"
fi
############################################
# Initialize ZSH Completion
############################################
# Prevents aliases on the command line from being internally substituted before completion is attempted.
# The effect is to make the alias a distinct command for completion purposes.
# setopt complete_aliases
# initialize autocomplete
autoload -U compinit add-zsh-hook
for dump in ~/.zcompdump(N.mh+24); do
compinit
done
# 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 _history
# show menu when more than 4 choices, menu has search enabled
zstyle ':completion:*' menu select=4 search
# prefer verbose option when available
zstyle ':completion:*' verbose yes
# Install kubecetl completion
[[ $commands[kubectl] ]] && source <(kubectl completion zsh)
############################################
# CELO Stuff
############################################
# Where you keep your Celo stuff
export CELO_ROOT=$CODE_DIR/celo
export CELO_BLOCKCHAIN=$CELO_ROOT/celo-blockchain
export CELO_MONOREPO=$CELO_ROOT/celo-monorepo
export GETH_BUILD_PATH=$CELO_BLOCKCHAIN/geth/build/bin/
# Your github handle
export HANDLE=gastonponti
# Run SSH Agent. Use ssh-add to add and remember keys for the session.
# celo-monorepo will need you to do this with your github key when updating geth dependencies.
# eval `ssh-agent`
alias celotooljs="$CELO_ROOT/celo-monorepo/packages/celotool/bin/celotooljs.sh"
alias celocli-dev="$CELO_ROOT/celo-monorepo/packages/cli/bin/run"
# lr: Full Recursive Directory Listing
# ------------------------------------------
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'
# mans: Search manpage given in agument '1' for term given in argument '2' (case insensitive)
# displays paginated result with colored search terms and two lines surrounding each hit. Example: mans mplayer codec
# --------------------------------------------------------------------
mans () {
man $1 | grep -iC2 --color=always $2 | less
}
# showa: to remind yourself of an alias (given some part of it)
# ------------------------------------------------------------
showa () { /usr/bin/grep --color=always -i -a1 $@ ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; }
# cdf: 'Cd's to frontmost window of MacOS Finder
# ------------------------------------------------------
cdf () {
currFolderPath=$( /usr/bin/osascript <<EOT
tell application "Finder"
try
set currFolder to (folder of the front window as alias)
on error
set currFolder to (path to desktop folder as alias)
end try
POSIX path of currFolder
end tell
EOT
)
echo "cd to \"$currFolderPath\""
cd "$currFolderPath"
}
# extract: Extract most know archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# ---------------------------
# 4. SEARCHING
# ---------------------------
alias qfind="find . -name " # qfind: Quickly search for file
ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory
ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string
ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string
# spotlight: Search for a file using MacOS Spotlight's metadata
# -----------------------------------------------------------
spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; }
############################################
# Rust
############################################
export PATH=$PATH:~/.cargo/bin/
############################################
# Python
############################################
eval "$(pyenv init -)"
############################################
# Android
############################################
#export ANDROID_HOME=/usr/local/share/android-sdk
export ANDROID_NDK=/usr/local/share/android-ndk
export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
# this is an optional gradle configuration that should make builds faster
export GRADLE_OPTS='-Dorg.gradle.daemon=true -Dorg.gradle.parallel=true -Dorg.gradle.jvmargs="-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError"'
############################################
export PATH=$PATH:$CELO_ROOT/solc