-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zsh.functions
204 lines (165 loc) · 4 KB
/
.zsh.functions
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
#!/bin/zsh
# Many of my projects have these scripts, so create nice
# aliases for them.
function version() {
curdir="$(pwd)"
while [[ ! -f $curdir/scripts/get_version.sh ]]; do
if [ "$curdir" = "/" ]; then
echo "No scripts/get_version.sh found."
return 1
fi
curdir=$(readlink -f "$curdir/..")
done
sh $curdir/scripts/get_version.sh
}
# A simple function that produces a git string for any
# repository the prompt is currently in.
#
# Example: git:repoName/master
#
function brname() {
if git status >/dev/null 2>&1; then
br="$(~/.local/bin/brname)"
echo "git%F{cyan}:%f$br "
fi
}
function fvim() {
vim -o `fzf`
}
function genhtml() {
sed -i 's;fail_under;#fail_under;g' .coveragerc
coverage report
coverage html
sed -i 's;#fail_under;fail_under;g' .coveragerc
if [ "$1" = '-o' ]; then
$BROWSER htmlcov/index.html
fi
}
function ssh() {
command ssh -4 "$@"
}
function py39() {
source $(pyenv root)/versions/3.9.5/envs/venv/bin/activate
}
function pytest-cov() {
rm -f .coverage
coverage run --append $(which pytest) "$@"
[[ $? -ne 0 ]] && return
coverage html
[[ $? -ne 0 ]] && return
coverage report
[[ $? -ne 0 ]] && return
}
function gslog() {
git log --pretty=oneline "$@" | sed -r 's/\(HEAD -> .*\)//'
}
function aur-coverage() {
./util/fix-coverage cache/.coverage
coverage html
coverage report
}
function backritty() {
screen -d -m alacritty -e tmux
exit
}
function mpclist() {
mpc playlist -f '%position%: %artist% - %title%' | grep "$*"
}
function aurbase() {
export PYTHONPATH=$(pwd)/..
}
function uviaur() {
AUR_CONFIG=/etc/aurweb/config uvicorn aurweb.asgi:app --reload --log-level debug
}
function activate() {
source ./venv/bin/activate
}
function py_installed() {
pip freeze
}
function aurweb-test() {
rm -f .coverage
AUR_CONFIG=conf/config make -C test
coverage report
coverage html
firefox htmlcov/index.html
}
function glog() {
git log --pretty=oneline "$@"
}
function _deploy() {
if [ -f './scripts/deploy.sh' ]; then
DEPLOY='./scripts/deploy.sh'
elif [ -f '../scripts/deploy.sh' ]; then
DEPLOY='../scripts/deploy.sh'
else
echo 'error: no $DEPLOY script found'
return 1
fi
bash $DEPLOY "$@"
}
function nano_deploy() {
export PORT='/dev/ttyUSB0'
export PART='atmega328p'
export PROGRAMMER='arduino'
export BAUD=115200
_deploy "$@"
}
function mega_deploy() {
export PORT='/dev/ttyACM0'
export PART='atmega2560'
export PROGRAMMER='wiring'
export BAUD=115200
_deploy "$@"
}
function siglent_screenshot() {
rm -f /tmp/siglent.bmp
lxi screenshot /tmp/siglent.bmp \
--address 192.168.0.91 \
--plugin siglent-sds >/dev/null 2>&1 | grep -q '^convert-.*:'
convert /tmp/siglent.bmp "$1"
}
function ffind() {
find . -type f "$@"
}
function dfind() {
find . -type d "$@"
}
function mastermerge() {
git checkout master
git pull origin master
git checkout "$1"
git merge master
git push origin "$1"
}
function aurtest() {
rm -f .coverage
echo "Initializing test DB..."
rm -f aurweb.sqlite3
AUR_CONFIG=conf/config python3 -m aurweb.initdb
AUR_CONFIG=conf/config coverage run $(which pytest) "$@" test
}
function aur-php-hyperfine() {
hyperfine --warmup 10 --min-runs 500 "curl --cookie AURSID=$AURSID https://localhost:8443/packages"
}
function aur-fastapi-hyperfine() {
hyperfine --warmup 10 --min-runs 500 "curl --cookie AURSID=$AURSID https://localhost:8444/packages"
}
function docker() {
if [ "$1" = "build" ]; then
command docker "$@"
command docker image prune -f
else
command docker "$@"
fi
}
function test() {
rm -f .coverage
pytest "$@"
}
function csv() {
perl -pe 's/((?<=,)|(?<=^)),/ ,/g;' "$@" | column -t -s, | less -F -S -X -K
}
function git-head() {
git rev-parse --short HEAD
}