-
Notifications
You must be signed in to change notification settings - Fork 2
/
bash_functions
95 lines (76 loc) · 1.98 KB
/
bash_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
### -*- shell-script -*-
# print PATH in a more readable format. handles any PATH like
# variable, but defaults to PATH
lspath () {
local var=${1:-"PATH"}
echo -e ${!var//:/\\n}
}
# clear history
hcl () {
size=$HISTSIZE
export HISTSIZE=0
export HISTSIZE=$size
}
cprove() {
cover -delete
PERL5OPT="-MDevel::Cover" prove "$@"
cover
}
pmversion () { perl -le "require $1; print $1->VERSION"; }
ipsort () { sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 "$@"; }
if which rpm2cpio >& /dev/null; then
xrpm () {
local pkg=$1
shift
rpm2cpio $pkg | cpio -ivd "$@"
}
fi
cleanenv () {
/usr/bin/env -i PATH=/usr/bin:/bin:/usr/X11R6/bin:/usr/sbin:/sbin \
HOME=$HOME \
TERM=$TERM \
"$@"
}
rpmbuild () { cleanenv /usr/bin/rpmbuild "$@"; }
dired () {
local dir=${1:-$PWD}
emacsclient -n -e "(dired \"$dir\")"
}
ediff () { emacsclient -n -e "(ediff \"$1\" \"$2\")"; }
#export-to-emacs () {
# code=$(echo '(progn'
# for var in "$@"; do
# echo "(setenv \"$var\" \"${!var}\")"
# done
# echo ')')
# emacsclient -e "$code" 1>/dev/null
#}
#
#emacs-ssh-agent () { export-to-emacs SSH_AGENT_PID SSH_AUTH_SOCK; }
#
nth () {
local F=$1
if [ $F == "-1" ]; then
F="NF"
fi
awk "{ print \$$F }"
}
# Display a growl notification using iTerm's magic escape sequence.
growl() {
local msg="\\e]9;\n\n${*}\\007"
case $TERM in
screen*)
echo -ne '\eP'${msg}'\e\\' ;;
*)
echo -ne ${msg} ;;
esac
return
}
#load-keychain() { source ~/.keychain/${HOSTNAME}-sh; }
# return true if the host is pingable.
up? () { ping -c 1 -w 1 $1 >& /dev/null; }
# reload keychain
rk () { source ~/.keychain/$(hostname)-sh; }
set-iterm-profile() { printf '\ePtmux;\e\e]1337;%s\007\e\\' "SetProfile=$1"; }
solarized-dark() { set-iterm-profile "SolarizedDark"; }
solarized-light() { set-iterm-profile "SolarizedLight"; }