-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions
73 lines (65 loc) · 1.39 KB
/
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
command_exists() {
command -v "$1" >/dev/null 2>&1
}
alias() {
if [ $# -eq 2 ] ; then
builtin alias $1="$2"
elif [ $# -eq 1 ] ; then
builtin alias "$*"
else
builtin alias
fi
}
# viw: vi `which binary`
viw() {
local tmp=`which $@`
if [ ! -z $tmp ]; then
vim $tmp
echo $tmp
fi
}
# tarcp: copies a directory via tar into another directory
tarcp() {
if [ $# == 2 ] && [ -d "$1" ] && [ -d "$2" ] ; then
tar --same-owner -cpf - "$1" | (cd "$2/"; tar --same-owner -xpf -)
else
echo Usage: tarcp dir-to-copy container-dir
fi
}
sshtunnel() {
if [ $# -ne 3 ] ; then
echo "usage: sshtunnel host remote-port local-port"
else
/usr/bin/ssh $1 -L $3:localhost:$2
fi
}
sshproxy() {
if [ $# -ne 4 ] ; then
echo "usage: sshproxy dest dest-port proxy proxy-port"
else
/usr/bin/ssh -N $3 -L $4:$1:$2
fi
}
quotes() {
local quotes=~/docs/quotes.txt
vi $quotes
if [ $quotes.dat -ot $quotes ] ; then
echo Updating quotes.
fortune -u $quotes
fi
}
archive_maildir() {
if [ $# != 0 ] ; then
while [ $# != 0 ]; do
if [ -d "$1" ] ; then
tar zcf "$1.tgz" "$1" && rm -rf "$1"
else
echo "'$1' is not a directory"
fi
shift
done
else
echo "usage: archive_maildir maildir1 [maildir2 ... maildirN]"
fi
}
# vim: ft=sh :