-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
executable file
·424 lines (348 loc) · 9.61 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
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
#ulimit -n 2560
export ZDOTDIR=$HOME
#Go setup
export GOPATH=$HOME/go
export GOBIN=$HOME/go/bin
export PATH=$PATH:$GOPATH/bin
#Elixir setup
export PATH="$PATH:/path/to/elixir/bin"
export GIT_TEMPLATE_DIR=$HOME/.git-templates
# z
. ~/z/z.sh
# Spotify TODO move to plugin directory
alias sp='~/Downloads/shpotify-master/spotify'
# SSH shortcuts
alias qa='ssh lkqa030'
alias st='ssh lkst030'
# CD aliases
alias apps='/Users/aweisberg/Sites/apps'
alias gems='/Users/aweisberg/Sites/gems'
alias cdapp='/Users/aweisberg/Sites/apps'
alias cdgem='/Users/aweisberg/Sites/gems'
# Git
alias g='git'
alias git='hub'
alias gce='git add --all && git commit -v'
#Bundler
alias be="bundle exec"
alias bl="bundle list"
alias bp="bundle package"
alias bo="bundle open"
alias bu="bundle update"
alias bi="bundle install"
alias bs="bundle show"
alias specs="bundle exec rspec -f d"
# Tmux
alias n='tmux new-session -s'
alias s='tmux switch -t'
alias a='tmux attach -d -t'
alias k='tmux kill-session -t'
alias t='tmux'
alias wemux='TERM=screen-256color-bce wemux'
# Neovim editor
alias vim="nvim"
alias v='nvim'
export NVIM_TUI_ENABLE_TRUE_COLOR=1
export EDITOR=vim
# Settings files
alias tmuxs="vim ~/.tmux.conf"
alias zshs="vim ~/.zshrc"
alias vims="vim ~/.vimrc"
alias nvims="vim ~/.nvim/nvimrc"
alias memcache="/usr/local/bin/memcached"
alias xml-post="curl -i -H \"Content-Type: text/xml\" -d @- -X POST"
#DISABLE_AUTO_TITLE=true
alias rfind='find . -name "*.rb" | xargs grep -n'
#Default editor
post () {
curl -i -H "Content-Type: application/${2:=json}" -d @- -X POST $1
}
get () {
curl -i -H "Content-Type: application/${2:=json}" -X GET $1
}
#FZF
# Copy the original fzf function to __fzf
#declare -f __fzf > /dev/null || eval "$(echo "__fzf() {"; declare -f fzf | \grep -v '^{' | tail -n +2)"
# Use git ls-tree when possible
#fzf() {
#if [ -n "$(git rev-parse HEAD 2> /dev/null)" ]; then
#FZF_DEFAULT_COMMAND="git ls-tree -r --name-only HEAD" command fzf "$@"
#else
#command fzf "$@"
#fi
#}
tojsx () {
for f in *.es6; do
mv -- "$f" "${f%.es6}.jsx"
done
}
api () {
curl -i --user JBR:7dc77e80793d673ad32fe7876961387d -H "Accept: application/json" -H "Content-Type: application/json; charset=US-ASCII" --data $1 http://api.gh.dev/gh/v1/bulk_loans
}
zr() {
rm ../../.zeus.sock
rm .zeus.sock
zeus start
}
unalias z
z() {
if [[ -z "$*" ]]; then
cd "$(_z -l 2>&1 | sed -n 's/^[ 0-9.,]*//p' | fzf)"
else
_last_z_args="$@"
_z "$@"
fi
}
fh() {
eval $(([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s | sed 's/ *[0-9]* *//')
}
#open file in vim
fv() {
local file
file=$(fzf --query="$1" --select-1 --exit-0)
[ -n "$file" ] && vim "$file"
}
# Equivalent to above, but opens it with `open` command
fo() {
local file
file=$(fzf --query="$1" --select-1 --exit-0)
[ -n "$file" ] && open "$file"
}
# fd - cd to selected directory
fd() {
local dir
dir=$(find ${1:-*} -path '*/\.*' -prune \
-o -type d -print 2> /dev/null | fzf +m) &&
cd "$dir"
}
# fda - including hidden directories
fda() {
local dir
dir=$(find ${1:-.} -type d 2> /dev/null | fzf +m) && cd "$dir"
}
# fbr - checkout git branch
fgc() {
local branches branch
branches=$(git branch) &&
branch=$(echo "$branches" | fzf +s +m) &&
git checkout $(echo "$branch" | sed "s/.* //")
}
# ftags - search ctags
ftags() {
local line
[ -e tags ] &&
line=$(
awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' tags |
cut -c1-80 | fzf --nth=1,2
) && $EDITOR $(cut -f3 <<< "$line") -c "set nocst" \
-c "silent tag $(cut -f2 <<< "$line")"
}
export FUZZY_SEARCH_PATHS="~/Projects:~/XCode:~/Sites/apps:~/Sites/gems"
fgrep() {
grep --line-buffered --color=never -r "" * | fzf
}
# This is a helper function that splits the current pane to start the given
# command ($1) and sends its output back to the original pane with any number of
# optional keys (shift; $*).
fzf_tmux_helper() {
[ -n "$TMUX_PANE" ] || return
local cmd=$1
shift
tmux split-window -p 50 \
"bash -c \"\$(tmux send-keys -t $TMUX_PANE \"\$(source ~/.fzf.bash; $cmd)\" $*)\"| vim"
}
# This is the function we are going to run in the split pane.
# - "find" to list the directories
# - "sed" will escape spaces in the paths.
# - "paste" will join the selected paths into a single line
fzf_tmux_dir() {
fzf_tmux_helper \
'find * -path "*/\.*" -prune -o -type d -print 2> /dev/null |
fzf --multi |
sed "s/ /\\\\ /g" |
paste -sd" " -' Space
}
# Bind CTRL-X-CTRL-D to fzf_tmux_dir
#bindkey '<ctrl-d>' "$(fzf_tmux_dir)\e\C-e"
function tag () {
ctags -R --languages=ruby --exclude=.git --exclude=log . $(bundle list --paths)
}
function apps_run () {
cd ~/Sites/apps/
for app in ./*
do
cd $app || echo "cannot cd into: ${app}"
echo "executing $@ in $app ..." && eval "$@" || echo "cannot execute: $1 in $app"
cd ~/Sites/apps/
done
}
for dir in ~/Sites/*
do
if [[ ${dir##*/} =~ 'apps|gems' ]]; then
for app in ~/Sites/${dir##*/}/*
do
eval "cd${app##*/} () { cd $app }"
eval "v${app##*/} () { cd $app && vim }"
done
fi
done
function dir_exec () {
cd $1
for path in ./*
do
cd $path || echo "cannot cd into: ${path}"
echo "executing $2 in $path ..." && eval "$2" || echo "cannot execute: $2 in $path"
cd .. || echo "cannot cd back from $path"
done
}
function gems_run () {
cd ~/Sites/gems
for gem in ~/Sites/gems/*
do
cd $gem
eval "$1" || "cannot execute: ${1} for ${gem}"
cd ~/Sites/gems
done
}
function all_run () {
apps_run $1
gems_run $1
}
function gem_vars () {
cd ~/Sites/gems
for gem in ~/Sites/gems/*
do
cd $gem
gem=$(basename $gem)
eval "export ${gem:u}_DIR=~/Sites/gems/${gem}"
done
}
function pry() {
if [ -e .zeus.sock ]; then
zeus console
elif [ -e bin/pry ]; then
bin/pry $@
else
command pry $@
fi
}
function rake() {
if [ -e .zeus.sock ]; then
zeus rake $@
elif [ -e bin/rake ]; then
bin/rake $@
else
command rake $@
fi
}
for bun_command in rake rspec
do
read -d '' func << EOM
${bun_command} () {
if [ -e bin/${bun_command} ]; then
bin/${bun_command} ${@}
else
command ${bun_command} ${@}
fi
}
EOM
eval "$func"
done
# Path to your oh-my-zsh installation.
#export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# time that oh-my-zsh is loaded.
# philips
#ZSH_THEME="robbyrussell"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to disable command auto-correction.
# DISABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
#COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
#plugins=(ruby brew git zsh-syntax-highlighting web-search)
#source $ZSH/oh-my-zsh.sh
# User configuration
export PATH=$HOME/bin:/usr/local/bin:$PATH
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"
export PATH=$PATH:~/bin
export PATH=$PATH:~/scripts
export PATH=/usr/local/bin:$PATH
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
# Teamocil autocomplete
#compctl -g '~/.teamocil/*(:t:r)' teamocil
# vim keybindings
bindkey -v
bindkey '^P' up-history
bindkey '^N' down-history
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
bindkey '^r' history-incremental-search-backward
bindkey -M viins 'jj' vi-cmd-mode
bindkey -M viins 'kk' clear-screen
# Move to where the arguments belong.
up-case-prev-word() {
zle vi-backward-word
zle up-case-word
}
zle -N up-case-prev-word
bindkey "^u" up-case-prev-word
#bash -e ~/Sites/configs/env/.bash_fynanz
#source ~/.powconfig
export HOMEBREW_CASK_OPTS="--appdir=/Applications"
export JAVA_HOME=$(/usr/libexec/java_home)
export JDK_HOME=$(/usr/libexec/java_home)
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
# Pipe output of previous command
alias _='fc -e - |'
# Fzf commands
source $HOME/plugins/fzf.zsh
source $HOME/configs/lkenv.sh
source $HOME/.zprezto/init.zsh
source $HOME/antigen.zsh
# Git helpers
source $HOME/plugins/git.zsh
# Plugins
antigen bundle git git-prompt
#antigen-theme robbyrussell
# Syntax highlighting
source $HOME/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh