-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzshfunctions
94 lines (79 loc) · 1.65 KB
/
zshfunctions
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
weather() {
curl -4 wttr.in/$1 2>/dev/null | less -Sc
}
for fun in 'ssh' 'mosh' 'hub'; do
alias $fun="ssh-add -l >/dev/null || ssh-add && unalias $fun; $fun"
done
gx-set() {
jq ".$1=\"$2\"" package.json | ifne sponge package.json
}
gx-github() { REPO=$(echo $(pwd) | sed -ne 's|^.*/\(github.com/.\)|\1|p')
if [[ ! -z ${REPO} ]]; then
gx-set author $(echo $REPO | cut -d'/' -f 2)
gx-set bugs.URL "https://$REPO/issues"
fi
}
gx-init() {
printf 'go\n\n' | gx init
gx-github
}
gx-checkdeps() {
gx-go rw
gx-go dvcs-deps
gx-go uw
}
gx-last() {
cat .gx/lastpubver
cut -f' ' -f 2 | ifne xsel
}
bak() {
for F; do
echo "cp" "$F"{,.bak}
cp -r "$F"{,.bak}
done
}
unbak() {
for F; do
NAME=$(basename "$f" .bak)
echo "cp -rf" "$NAME"{.bak,}
cp -fr "$NAME"{.bak,}
done
}
pingr() {
ping $(ip r get 8.8.8.8 | cut -d' ' -f 3)
}
send-terminfo() {
ssh "$1" mkdir -p .terminfo/x/
scp /usr/share/terminfo/x/xterm-termite "$1:.terminfo/x/"
}
terminfo() {
< /home/kubuxu/dotfiles/termite/install.sh xsel -b
}
edc() {
echo 4 k "$@" p | dc
}
work_search() {
echo "Searching for '$1'"
xdg-open "https://github.com/search?q=org%3Aipfs+org%3Alibp2p+org%3Amultiformats+org%3Aprotocol+org%3Aipld+$1&type=Issues"
}
drop-caches() {
for c in $(seq 1 3); do
echo $c | sudo tee /proc/sys/vm/drop_caches
done
}
highlight() {
declare -A fg_color_map
fg_color_map[black]=30
fg_color_map[red]=31
fg_color_map[green]=32
fg_color_map[yellow]=33
fg_color_map[blue]=34
fg_color_map[magenta]=35
fg_color_map[cyan]=36
fg_c=$(echo -e "\e[0;${fg_color_map[$1]}m")
c_rs=$'\e[0m'
sed -u -E s"/$2/$fg_c\0$c_rs/g"
}
base64url() {
base64 "$@" | tr '/+' '_-' | tr -d '='
}