-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_alias
264 lines (240 loc) · 7.16 KB
/
bash_alias
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#! /bin/bash
# enable color support of ls and also add handy aliases
if [ -e /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
alias l='ls -lh' # make it colored _but_ >long< and human readable
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
alias rm="rm -i"
# PROMPT STUFF #
# - this is a hack to not crum everything in one
# line as well as keeping the quotas clear
function battery() {
[ "x$(acpi | grep 'Dis' -o )" = "xDis" ] && echo -n '!'
}
alias mutt="mutt -F ~/.muttrc"
alias mutts="mutt -F ~/.muttrc_serious"
alias make-mykernel="KBUILD_VERBOSE=1 make-kpkg --initrd --bzimage --jobs 5 --rootcmd fakeroot --revision 01 kernel_image"
alias emc="emacsclient -c -nw"
alias manifest="find -type f | grep -v 'git' | sed s:^\./::g > MANIFEST"
alias id3rename='id3rename -w -p "{track} - {title}" -d "/home/andreas/share/audio/{artist}/{album}"'
alias t_id3rename='id3rename -t -w -p "{track} - {title}" -d "/home/andreas/share/audio/{artist}/{album}"'
alias d_id3rename='id3rename -w -p "{track} - {title}" -d "/home/andreas/share/audio/{artist}/{album}/{disk}"'
alias td_id3rename='id3rename -t -w -p "{track} - {title}" -d "/home/andreas/share/audio/{artist}/{album}/{disk}"'
alias server="python -mSimpleHTTPServer"
function from_epoch
{
perl -MDateTime -e '$dt = DateTime->from_epoch( epoch => '$1'); print $dt->ymd," ",$dt->hms;'
}
function iscentos() {
ssh $1 "test -e /etc/centos-release && echo Is Centos"
}
function ocsp_check() {
openssl s_client -connect $1:443 -tls1 -tlsextdebug -status
}
function self_signed() {
openssl genrsa -out $1\.key 2048
openssl req -new -x509 -key $1\.key -out $1\.cert -days 3650 -subj /CN=$1
}
function cleanmusic() {
for i in '*.log' '*.CUE' '*.cue' '*.m3u' '*.jpg' '*.m3u8';
do
find -name "$i" -delete || continue
done
}
## for git
function git_count()
{
echo -n "$(git status -s | awk '{count[$1]++}END{for(j in count) printf j ": " count[j]" "}')$(git status | grep 'by [0-9]* commits' -o | sed 's/by \([0-9]*\) commits/C: \1/g')"
}
function git_branch()
{
git branch 2>/dev/null >/dev/null && \
echo -n $(git branch | grep '^\*' | cut -d" " -f2-) "[$(git_count | sed s:\ $::g)]"
}
function _vcs_check()
{
if [ -z $NO_VCS_NOW ]; then
if [ ! -z "$(svn_check)" ]; then
echo -n $(svn_check)" "
return 0
elif [ ! -z "$(git_branch)" ]; then
echo -n $(git_branch)" "
return 0
fi
fi
}
function toggle_vcs()
{
if [ -z $NO_VCS_NOW ]; then
export NO_VCS_NOW=1
else
export NO_VCS_NOW=
fi
}
## for svn
alias svn_check='test -d .svn/ && echo "(rv$(svn info | grep "Revision" | cut -d: -f2 | sed s/\ //g))"'
# general development
alias emacs="emacs24 -nw -f server-start"
alias m='make'
# misc
alias g='git'
alias s='source ~/.bashrc'
alias getproc='ps awxf -o pid,ni,pcpu,%mem,wchan,cmd | grep -v "grep" | grep -i '
alias aptitude='sudo aptitude'
alias apt-get='sudo apt-get'
alias diff='diff -Naur'
alias pastebin='curl -F "sprunge=<-" http://sprunge.us'
alias rot13="tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]'"
alias cpus="lscpu -p | awk 'BEGIN{FS=","}{$cpuid[$i++] = $1}END{print $cpuid[0]+1}'"
alias pcsx="pcsx -nogui -cdfile"
alias virsh="virsh --connect=qemu+ssh://root@localhost/system"
function mkhpiso
{
if [ -z $1 ]; then
echo "mkhpiso src dst"
return
fi
genisoimage -N -J -joliet-long \
-b system/isolinux.bin \
-c system/boot.cat \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table -o $2 $1
}
function presentation() {
export PRESENTATION=1
source ~/.bashrc
}
function rmtmp()
{
find -name '*~' -delete
find -name '*.elc' -delete
# Remove build dirs only when we are in a cmake project
if [ -d build/ ];then
rm -rf build/
fi
# When working with pdflatex
find -name '*.out' -delete
find -name '*.toc' -delete
find -name '*.log' -delete
find -name '*.aux' -delete
}
function cbuild()
{
rmtmp
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Debugfull -DCMAKE_INSTALL_PREFIX=/usr .. && \
make -j3 && cd ..
}
function lintian-check()
{
for i in $(ls -1 *.deb)
do
echo -e "\033[00;32m * $i \033[00;00m"
lintian --check --pedantic -I --color always -o $i
done
}
# TODO: is there more todo here otherwise?
function less()
{
if [ "x$@" = "x" ]; then
/bin/less
else
if [ ! "x$(echo $@ | grep .pdf)" = "x" ]; then
pdftotext $@
pdf_file="$(echo "$@" | sed s:\.pdf:\.txt:)"
/bin/less $pdf_file && rm $pdf_file
elif [ -d $@ ]; then
ls $@
elif [ ! "x$(echo $@ | grep '.[Hh][Tt][Mm][Ll]')" = "x" ]; then
w3m $@
elif [ ! "x$(echo $@ | grep .ps)" = "x" ]; then
ps2txt -layout $@ | /bin/less
# ps_file="$(echo "$@" | sed s:\.ps:\.txt:)"
# $ps_file && rm $ps_file
elif [ ! "x$(echo $@ | grep '\(.c\|.cpp\|.h\|hpp\|.pl\|.sh\)')" = "x" ]; then
vim $@ -R
elif [ ! "x$(echo $@ | grep '\(.tar.\(gz\|bz2\)\|.zip\|.tgz\|.deb\)' )" = "x" ]; then
lesspipe $@ | /bin/less
elif [ "$(file --mime-type $@ | cut -d: -f2 | cut -d/ -f1 | sed s/\ //g)" = "image" ];then
feh $@
else
vim $@ -R -c 'syntax on'
fi
fi
}
seq_al() {
echo | awk '{ for(i=97;i<123;i++) { printf "%c\n",i }}'
}
# Makes a screen grab from your current screen
make_video() {
ffmpeg -f x11grab -r 25 -s $(xrandr -q | grep '\*\+' | grep -o '[0-9]*x[0-9]*') -i :0.0 $@
}
function mailqcount () {
mailq | grep @ | cut -d'@' -f2 | sort | awk '{count[$1]++}END{for(j in count) printf count[j] "\t" j" \n"}' | sort -g
}
### __COMMENTS__
## _OLD_UNUSED_BUT_INTERESTING_SNIPPETS_
# DEPRECATED elisp update script
#-------------------------------
# NOTE: kept for reference
# function elisp_update_git()
# {
# cur_dir=$(pwd)
# root_dir=$HOME/.elisp
# cd $root_dir
# for i in $(find -name .git)
# do
# echo -e '\033[01;33m'$i'\033[00;00m'
# git_repo=$root_dir/$(echo $i | sed s/.git// | sed s:./::)
# cd $git_repo && echo $git_repo && git pull || echo "ERROR $!"
# done
# cd $cur_dir
# }
#-------------------------------
# second version... just use mr or git submodules
#-------------------------------
# function elisp_update_git()
# {
# cur_dir=$(pwd)
# root_dir=$HOME/.elisp
# cd $root_dir
# for i in $(find -maxdepth 2 -regex '\(.*/\.git\|.*/\.svn.*\)')
# do # only search next dir below $root_dir
# echo -e '\033[01;33m'$i'\033[00;00m' #bits of color
# subdir=$root_dir/$(echo $i | sed 's:\(\./\|\.git\|/\.svn\)::g')
# if [ -d $subdir/.svn ]
# then
# cd $subdir && svn up 1>/dev/null
# elif [ -d $subdir/.git ]
# then
# cd $subdir && git pull 1>/dev/null
# fi
# done
# cd $cur_dir
# }
#-------------------------------
# kept for sentimental reasons :)
#-------------------------------
# function moovida()
# {
# for i in $( ps ax | grep irxevent | cut -d" " -f1 );
# do
# kill $i
# done
# irxevent --daemon
# /usr/bin/moovida $@
# }
#-------------------------------
# Old func for creating script tags ( I'm lazy sometimes...)
#-------------------------------
# function js_script()
# {
# for i in $(ls);do echo '<script src="js/libs/'$i'"></script>';done
# }