-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions
executable file
·88 lines (76 loc) · 1.61 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
# shell functions
# colorize
color() {
color=${1}; shift
text=${@}
echo -n "[3${color}m${text}[00m"
}
lightcolor() {
color=${1}; shift
text=${@}
echo -n "[9${color}m${text}[00m"
}
# take a desktop screenshot
dscrot() {
maim "$TMPDIR/tmp.png"
optipng -o7 "$TMPDIR/tmp.png"
MD5=$(md5sum "$TMPDIR/tmp.png" | awk '{print $1}')
/bin/mv "$TMPDIR/tmp.png" "$HOME/media/img/Screenshots/$MD5.png"
}
# start things in new X server
ox() {
xinit $(which $1) -- :1
}
# dtach manager
dt() {
sockets="$TMPDIR/dtach"
if [ -n "$1" ]; then
case "$1" in
list|ls) ls -1 "$sockets"/* | sed s:$sockets/:: ;;
rtorrent|rt) dtach -A "$sockets/rtorrent" rtorrent ;;
*) dtach -A "$sockets/$1" -e $(shift; echo $@)
esac
else
echo "No application or socket specified."
fi
}
# extract files
x () {
if [ -f "$1" ] ; then
case "$1" in
*.rar) unrar x "$1" ;;
*.tar) tar xvf "$1" ;;
*.xz) xz -d "$1" ;;
*.Z) uncompress "$1" ;;
*) bsdtar -xf "$1" || echo "Unable to extract $1." ;;
esac
else
echo "Usage: x [files]"
fi
}
# convert bdf to pcf
mkpcf() {
for file in *.bdf; do
bdftopcf -o "${file%\.*}.pcf" "$file"
done
}
# make patch
mkpatch() {
diff -Naur $1 $2 > $3
}
# run last command as root
whoops() {
sudo -p "(⇀‸↼‶): " $(fc -nlr | sed 1q)
}
# manpages with colors
man() {
env LESS_TERMCAP_mb=$(printf '\e[01;31m') \
LESS_TERMCAP_md=$(printf '\e[01;38;5;74m') \
LESS_TERMCAP_me=$(printf '\e[0m') \
LESS_TERMCAP_se=$(printf '\e[0m') \
LESS_TERMCAP_so=$(printf '\e[38;5;246m') \
LESS_TERMCAP_ue=$(printf '\e[0m') \
LESS_TERMCAP_us=$(printf '\e[04;38;5;146m') \
man "$@"
}