-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzshrc
More file actions
379 lines (294 loc) · 10.1 KB
/
Copy pathzshrc
File metadata and controls
379 lines (294 loc) · 10.1 KB
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
# oh-my-zsh stuff
#
ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git git-flow autojump history-search-multi-word)
source $ZSH/oh-my-zsh.sh
# my own stuff
alias .='source'
#alias ls='ls --color=always' # ls='ls --color=auto'
alias l='ls -l'
alias ll='ls -lA'
alias L='ls -l | less'
alias LL='ls -la | less'
alias lg='ls -l | grep -i'
alias llg='ls -la | grep'
alias mv='mv -i'
alias cp='cp -i'
#alias rm='rm -I'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias cd.....='cd ../../../..'
#alias less='less -rM'
alias less='less -R'
#alias mplayer='mplayer -really-quiet'
alias no='yes n'
alias svi='sudo -E vi'
alias grep='grep --color'
alias speedtest='wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip'
# git stuff
alias gff='git flow feature'
alias gfr='git flow release'
alias gfh='git flow hotfix'
alias gl='git pull --stat'
alias gco-='git checkout -'
alias glp='git log --patch'
alias gpp='git push -u origin $(git rev-parse --abbrev-ref HEAD)'
alias gr='git pull -r'
alias gss='git stash show'
alias gssp='git stash show -p'
alias gsd='git stash drop'
alias gsp='git stash pop'
alias gsl='git stash list'
alias gg='git --no-pager'
alias gcb='git rev-parse --abbrev-ref HEAD'
pg() {
(ps aux | head -n 1) && (ps aux | grep -i $1)
}
color() {
grep -E "$1|" --color=always $2
}
# TODO
# if [[ $IS_MAC -eq 1 ]]; then
# Only if in an X environment
if [[ $(uname) != "Darwin" && -n $DISPLAY ]]; then
setxkbmap se
setxkbmap -option ctrl:nocaps
xset -b # beep off
fi
if [[ $(uname) == 'Darwin' ]]; then
export CLICOLOR_FORCE=1
alias ls='ls -G'
fi
if [[ $(uname) == 'Darwin' ]]; then
alias text='open -a textedit'
fi
if [ -e ~/.pythonstartup ]; then
export PYTHONSTARTUP=~/.pythonstartup
fi
# LINUX
AUTOJUMP_PATH=/usr/share/autojump/autojump.sh
if [ -e $AUTOJUMP_PATH ]; then
. $AUTOJUMP_PATH
else
AUTOJUMP_PATH=/usr/local/etc/autojump.sh
if [ -e $AUTOJUMP_PATH ]; then
. $AUTOJUMP_PATH
fi
fi
export VIRTUALENV_PYTHON=~/.virtualenvs/otto/bin/python3
export VIRTUALENV_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
if [ -e $VIRTUALENV_SCRIPT ]; then
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects
. $VIRTUALENV_SCRIPT > /dev/null 2>&1
fi
bindkey \^V history-incremental-search-backward
bindkey \^W backward-kill-word
bindkey \^U backward-kill-line
# bindkey '^P' up-line-or-search # make ^P behave exactly like arrow up
bindkey '^P' up-line-or-history
#DISABLE_AUTO_UPDATE='true'
#CASE_SENSITIVE="true"
#setopt autocd
#setopt extendedglob
#setopt appendhistory autocd extendedglob nomatch
setopt no_share_history
setopt hist_find_no_dups
setopt hist_ignore_space
# treat jobs like bash do
setopt no_hup
setopt no_check_jobs
# smarter completion
setopt nolistambiguous
setopt menu_complete
setopt no_case_glob
setopt auto_pushd
# this is because
# rm foo 2>/dev/null works when foo is not present, but
# rm foo* 2>/dev/null
# doesn't...
setopt null_glob
unsetopt correct_all
unsetopt beep notify
export EDITOR=vim
set -o emacs
zstyle ':completion:*:*:vi:*:*files' ignored-patterns '*.pyc'
zstyle ':completion:*:*:vim:*:*files' ignored-patterns '*.pyc'
autoload zmv
alias o='popd'
alias rdesktop="LC_ALL=sv_SE.UTF-8 rdesktop"
if [ -e /usr/bin/md5sum ]; then
alias md5='md5sum'
fi
if [ -e /usr/bin/colordiff ]; then
alias diff=colordiff
fi
#eval "$(pip completion --zsh)"
if [[ -e ~/.pythonstartup ]]; then
export PYTHONSTARTUP=~/.pythonstartup
fi
alias py.test='python -m py.test -s -l --tb=short --strict'
alias pbp='pbpaste'
alias pjq='pbpaste | jq'
alias pbc='pbcopy'
flow-stat() {
git --no-pager diff develop..HEAD --numstat | \
awk '{ a+=$1; b+=$2 } END {print "Added:\t\t" a "\n" "Deleted:\t" b}'
}
statistics() {
num_files=$(find . -type f -regex '.*\.py$' | wc -l)
num_lines=$(find . -type f -regex '.*.py$' | xargs -I {} wc -l {} | awk '{ a+=$1 } END { print a }')
echo "Files: $num_files"
echo "Lines: $num_lines"
}
grepv() {
cmd="grep -v $1"
shift
for arg in $@; do
cmd="$cmd | grep -v $1"
shift
done
eval $cmd
}
export LANG=en_US.UTF-8
alias listening-ports='lsof -i -P | grep "LISTEN"'
alias compile-ssh-config='rm ~/.ssh/config && cat ~/.ssh/*.conf >> ~/.ssh/config'
alias sudo='sudo ' # If the last character of the alias value is a space or tab character,
# then the next command word following the alias is also checked for alias expansion.
alias textedit='open -a /Applications/TextEdit.app'
alias pip-upgrade-all='pip list --outdated | tail +1 | awk '"'"'{ system("pip install -U "$1) }'"'"''
# rlwrap for the win
alias redis-cli='rlwrap redis-cli'
alias racket='rlwrap racket'
alias lisp='rlwrap sbcl'
alias node="env NODE_NO_READLINE=1 rlwrap node"
alias wetter='curl http://wttr.in/Hamburg'
alias gitx='open -a /usr/local/Caskroom/rowanj-gitx/0.15,1964/GitX.app .'
lat() {
if [[ -z $1 ]]; then NO=10
else NO=$1 fi
ls -lt | tail -n +2 | head -n $NO
}
# just for now...
alias startpostgres='/usr/local/bin/postmaster -D /usr/local/var/postgres &'
alias dirsizes='find . -type d -maxdepth 1 -exec sh -c "du -h {} | tail -n 1" \;'
alias deleteempty='find . -empty -print -delete'
dirwise() {
for d in `find . -type d -maxdepth 1`; do
(cd $d && pwd)
done
}
export HOMEBREW_LOGS=/usr/local/var/log/
alias dir='\ls -d */'
alias lwcl='ls -l | wc -l'
alias reload='source ~/.zshrc'
tailf() {
while ! tail -f $1 2>/dev/null; do sleep 1; done
}
alias -g G='| grep'
alias -g V='| grep -v'
alias -g W='| wc -l'
alias -g E='| xargs -o vi'
alias -g J='| jq'
highlight() { grep --color -E "$1|$" }
alias -g HL='| highlight'
alias -g X='| xargs'
alias -g L='| less'
alias -g H='| head'
alias -g T='| tail'
f() {
find . -iname "*$1*" -print
}
fe() { find . -name $1 -print }
#e() {
# pss "$1" -l | xargs -o vi
#}
gi() {
grep -ri $1 .
}
alias find='noglob find'
alias zmv='noglob zmv -W'
alias jq='noglob jq'
BACKUP_PATH=$HOME/Dropbox/backup
alias backup='borg create -v --stats --progress $BACKUP_PATH::backup-{now:%Y-%m-%d} $HOME/Desktop/first\ Project $HOME/documents $HOME/Downloads $HOME/Music $HOME/Pictures $HOME/projekt $HOME/code $HOME/passwd.kdbx $HOME/.task'
alias backup-list='borg list $BACKUP_PATH'
alias backup-prune='borg prune --keep-last 1 $BACKUP_PATH'
alias airport=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
alias wifi-connect='networksetup -setairportnetwork en0'
split() {
python -c "import sys, itertools as it; print '\n'.join(it.chain.from_iterable(line.split('$1') for line in sys.stdin.readlines()))"
}
new-mac() {
mac=$(python -c "import random; data=hex(random.getrandbits(48))[2:-1]; print ':'.join(map(''.join, zip(*[iter(data.zfill(12))]*2)))")
sudo ifconfig en0 ether $mac
}
wifi() {
new-mac
wifi-connect $1 $2
}
alias list-timezones='sudo systemsetup -listtimezones'
week() { python -c "from datetime import datetime; print(datetime.now().isocalendar()[1])" }
alias date-berlin='TZ=Europe/Berlin date'
alias date-ny='TZ=US/Eastern date'
alias ipy="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
alias https='http --default-scheme=https'
# quick n dirty for swagger output
find-url() {
jq '.paths | to_entries[] | select (.key == "$1") .value'
}
#alias pip='pip --no-cache'
alias tree='tree -I __pycache__'
alias pyclean='find . -type d -name __pycache__ -exec rm -rf {} \;'
#alias psql=/Applications/Postgres.app/Contents/Versions/9.4/bin/psql
alias my-ip='dig TXT +short o-o.myaddr.l.google.com @ns1.google.com'
workon otto2
export PATH=$PATH:$HOME/bin:/usr/local/opt/python@3.8/bin:/usr/local/bin:/usr/local/sbin:$PATH:~/bin:$HOME/projects/nav_scripts
alias swamp-nav-nonlive-readonly="swamp -account 652837427747 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-nonlive-readonly -target-role readonly"
alias swamp-nav-nonlive-developer="swamp -account 652837427747 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-nonlive-developer -target-role developer"
alias swamp-nav-nonlive-admin="swamp -account 652837427747 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-nonlive-admin -target-role admin"
alias swamp-nav-live-readonly="swamp -account 758683619057 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-live-readonly -target-role readonly"
alias swamp-nav-live-developer="swamp -account 758683619057 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-live-developer -target-role developer"
alias swamp-nav-live-admin="swamp -account 758683619057 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-live-admin -target-role admin"
alias swamp-nav-infrastructure-readonly="swamp -account 230874101425 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-infrastructure-readonly -target-role readonly"
alias swamp-nav-infrastructure-developer="swamp -account 230874101425 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-infrastructure-developer -target-role developer"
alias swamp-nav-infrastructure-admin="swamp -account 230874101425 -mfa-device arn:aws:iam::027617375449:mfa/fmelande -target-profile nav-infrastructure-admin -target-role admin"
alias jj='jet --from edn --to json | jq .'
export PATH=$HOME/bin:$PATH
alias -g B='| bb -i -e'
alias jag='ag --clojure'
#alias bb='rlwrap bb'
alias pc="pwd | pbcopy"
_bb_tasks() {
local matches=(`bb tasks|tail -n +3|cut -f1 -d ' '`)
compadd -a matches
}
compdef _bb_tasks bb
eval export PATH="/Users/fmelande/.jenv/shims:${PATH}"
export JENV_SHELL=zsh
export JENV_LOADED=1
unset JAVA_HOME
unset JDK_HOME
source '/usr/local/Cellar/jenv/0.5.5_2/libexec/libexec/../completions/jenv.zsh'
jenv rehash 2>/dev/null
jenv refresh-plugins
jenv() {
type typeset &> /dev/null && typeset command
command="$1"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
enable-plugin|rehash|shell|shell-options)
eval `jenv "sh-$command" "$@"`;;
*)
command jenv "$command" "$@";;
esac
}
export PATH="/usr/local/opt/openjdk@11/bin:$PATH"
alias ag='ag -i'