-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfun.sh
79 lines (64 loc) · 1.37 KB
/
fun.sh
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
bak() {
cp -ri "$1"{,.bak}
}
open() {
# open_command https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/functions.zsh
local p=${1:-.}
command open "$p"
}
mkcd() {
mkdir -p "$@" && cd "$@"
}
stext() {
if [[ $# -eq 1 ]]; then
grep -irn "$1" . \
--exclude-dir={.git,node_modules}
else
grep -in "$@" \
--exclude-dir={.git,node_modules}
fi
}
sfile() {
find . -iname "$@"
}
sdir() {
find . -type d -iname "$@"
}
scmd() {
if $(type "$1" | grep -q 'is a shell function'); then
type "$1"
which "$1"
elif $(type "$1" | grep -q 'is an alias'); then
PS4='+%x:%I>' zsh -i -x -c '' |& grep '>alias ' | grep "${1}="
fi
}
dudir() {
local depth=${1:-1}
du -hd "$depth"
}
pbsort() {
clippaste | sort | clipcopy
}
pbuniq() {
clippaste | cat -n | sort -k2,2 -k1,1n | uniq -f1 | sort -k1,1n | cut -f2- | clipcopy
}
pyserver() {
# python2 -m SimpleHTTPServer "$@"
python3 -m http.server "$@"
}
checkport() {
lsof -nP -iTCP:"$1"
}
sip() {
# https://stackoverflow.com/questions/3097589/getting-my-public-ip-via-api
# curl ipinfo.io "$@"
curl ifconfig.me "$@"
}
git_change_date() {
local d=$1
GIT_COMMITTER_DATE="$d" git commit --amend --no-edit --only --date="$d"
}
git_reset_date() {
# git rebase -i HEAD^ -x "git commit --amend --author 'name <[email protected]>' --no-edit"
git rebase --committer-date-is-author-date -i "$@"
}