-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc.local
109 lines (83 loc) · 2.7 KB
/
.zshrc.local
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
eval "$(SHELL=/bin/sh lesspipe)"
alias pscp="pscp -x '-o \"StrictHostKeyChecking no\"'"
alias pssh="parallel-ssh -x '-o \"StrictHostKeyChecking no\" -o \"VisualHostKey no\"'"
alias burn="wodim -v -eject"
export PATH="$PATH:/sbin:/usr/sbin"
function .finddeadlinks () {
find $1 -type l ! -exec test -r {} \; -print
}
function .reinject () {
python -c "
import os
import sys
import subprocess
# missing = [fname for f in ([os.readlink(fname) for fname in os.listdir('.') if os.path.islink(fname)]) if not os.path.exists(f)]
def getmissing(dir_):
for fname in os.listdir(dir_):
path = os.path.join(dir_, fname)
if not os.path.islink(path):
continue
if not os.path.exists(os.readlink(path)):
yield fname
missing = list(getmissing('.'))
SRCDIR = sys.argv[1]
for fname in os.listdir(SRCDIR):
path = os.path.join(SRCDIR, fname)
if os.path.exists(path) and fname in missing:
subprocess.call(('git', 'annex', 'reinject', path, fname))
" $1
}
function macinfo () {
python3 -c "
from netaddr import EUI
from sys import argv
print (EUI(argv[1]).info)
" $1
}
function randomip6addr () {
python3 -c "
from random import choice
CH='0123456789abcdef'
a = ''.join([choice(CH) for i in range(16)])
print('%s:%s:%s:%s' % (a[:4], a[4:8], a[8:12], a[12:]))
"
}
unsetopt correct
unsetopt share_history
zstyle ':completion:*' hosts off
export PATH="$PATH:/usr/local/go/bin"
function flacsplit () {
cuebreakpoints "${1}"|shnsplit -o flac "${2}"
cuetag "${1}" split-track*.flac
}
function convert_mp3 () {
shift
parallel -j 3 'a={}; avconv -i "$a" -qscale:a 4 "${a[@]/%flac/mp3}"' ::: $@
}
# Python virtuelenv fix for tmux
if [ -n "$VIRTUAL_ENV" ]; then
source "$VIRTUAL_ENV/bin/activate"
fi
# pretty print SQL
alias sqlf='sqlformat --reindent --keywords upper --identifiers lower'
# convert JSON to YAML. This improves readability of RESTful JSON APIs
alias json2yaml="python -c 'import sys, yaml, json; yaml.safe_dump(json.load(sys.stdin), sys.stdout, default_flow_style=False)'"
function gluster-search () {
pssh -i -H kvm01 -H kvm02 -H kvm03 "ls /export/brick1/kvm/images/|grep \"${1}\""
}
alias sqlf='sqlformat --reindent --keywords upper --identifiers lower'
function whattecommit () {
git commit -m "$(wget -O - -q http://whatthecommit.com/|hxselect '#content >p' -c|grep -v href)"
}
function sshp () {
export http_proxy=http://127.0.0.1:8888
export https_proxy=http://127.0.0.1:8888
ssh -R 8888:127.0.0.1:8888 -o SendEnv=http_proxy -o SendEnv=https_proxy "$@"
unset https_proxy
unset http_proxy
}
RED=$'%{\e[1;31m%}'
NO_COLOR=$'%{\e[0m%}'
if [[ ! -z "${VIMRUNTIME}" ]]; then
PROMPT="${RED}VIM ${NO_COLOR}${PROMPT}"
fi