-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.aliases
More file actions
426 lines (356 loc) · 10.9 KB
/
.aliases
File metadata and controls
426 lines (356 loc) · 10.9 KB
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
#!/bin/bash -
#description :
#author :Michele Gazzetti
#date :29.11.17
#notes :
#==============================================================================
#------- to test
#get_virtualenv_name(){
#virtualenv_info | awk -F ':' '{print $2}'
#}
#alias nosetests='/home/$USER/.virtualenvs/$(get_virtualenv_name)/bin/nosetests'
alias gen-ycm-conf="~/.vim/plugged/YCM-Generator/config_gen.py ."
pingme(){
notify-send 'Done !!!'
}
dip(){
docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$1"
}
#docker remove all images
dira(){
docker rmi $(docker images | awk 'NR>=2 {print $3}')
}
sv(){
echo "#" >> ~/.commands.sh
history -d $((HISTCMD-1)) && fc -nl $((HISTCMD - 1)) | sed '1s/^[[:space:]]*//\' >> ~/.commands.sh
}
alias nautilus='nautilus --no-desktop'
####
## Git relate aliases
####
alias g='git'
alias gp='git push'
#Remove the files named a.out frequently.
alias rmao="find . -iname a.out -exec rm {} \;"
#Remove the core files generated by c program.
alias rmc="find . -iname core -exec rm {} \;"
alias rmswp="find . -type f -name ".*.swp" -exec rm -f {} \;"
#showcd(){
#cd "$1"
#ls
#}
#alias cd="showcd"
alias p='source ~/.bash_profile'
#alias sc='echo "#" >> ~/.commands.sh && fc -nl $((HISTCMD - 1)) | sed \''1s/^[[:space:]]*//\'' >> ~/.commands.sh && sed -i "/sc/d" $HISTFILE'
#alias sc='echo "#" >> ~/.commands.sh && history -d $((HISTCMD-1)) && fc -nl $((HISTCMD - 1)) | sed \''1s/^[[:space:]]*//\'' >> ~/.commands.sh'
alias sc=' fc -ln "$1" "$1" | sed "1s/^[[:space:]]*//" >> ~/.commands.sh && echo "#">> ~/.commands.sh'
alias oc='vim ~/.commands.sh'
alias ocb='vim ~/.notes/bash'
alias ocp='vim ~/.notes/py'
alias ocv='vim ~/.notes/cvim.vim'
alias ocg='vim ~/.notes/cgit'
alias ock='vim ~/.notes/ckura'
alias oct='vim ~/.notes/ctmux'
alias urxvt='urxvt -name =)'
alias op='vim ~/.profile'
alias oa='vim ~/.aliases'
alias om='vim ~/.manual.sh'
#personal manual (need pandoc)
alias modman='vim ~/.manual.md'
#alias vman='pandoc -s -f markdown -t man ~/.manual.md | groff -T utf8 -man | less'
alias dsa='docker stop $(docker ps -a -q)'
alias dra='docker rm $(docker ps -a -q)'
# change keyboard layout --> find layout in /usr/share/X11/xkb/symbols
alias itkey='setxkbmap it && notify-send "keyboard=it" && xmodmap ~/.Xmodmap'
alias uskey='setxkbmap us && notify-send "keyboard=us" && xmodmap ~/.Xmodmap'
alias xmp='xmodmap ~/.Xmodmap'
#-- awesome
alias awr='echo "awesome.restart()" | awesome-client > /dev/null 2>&1'
#-- docker
alias d='docker'
phist(){
#needs to check if number
re='^[0-9]+$'
case $# in
0)
echo 'need at least starting number'
;;
1)
#if $2 is not a number
if [ -z "$1" ]; then
echo '2nd arg needs to be a number'
else
#history | awk -v ref="$1" "FNR>=ref"'{$1=""; print $0}'
history | awk "FNR>=$1"'{$1=""; print $0}'
fi
;;
2)
if [[ $1 == "-c" ]]; then
#TODO: print last $2 lines
history | tail -"$2" | awk '{$1=""; print $0}'
exit 0
fi
#if $2 is not a number
if [ -z "$1" -o -z "$2" ]; then
echo 'args need to be a numbers'
else
history | awk "FNR>=$1 && FNR<=$2"'{$1=""; print $0}'
fi
;;
esac
}
#------- to test
alias grep='grep --color=auto'
# some more ls aliases
alias ll='ls -ahlF'
#alias la='ls -A'
alias l='ls -CF'
#alias install='sudo apt-get install'
#alias update='sudo apt-get update'
#alias upgrade='sudo apt-get -u upgrade'
alias agi='sudo apt-get install'
alias agu='sudo apt-get update'
#alias agg='sudo apt-get -u upgrade'
# personal aliases
#alias ls='ls -hF --color' # add colors for filetype recognition
alias lx='ls -lXB' # sort by extension
alias lk='ls -lSr' # sort by size
alias la='ls -Al' # show hidden files
alias lr='ls -lR' # recursice ls
alias lt='ls -ltr' # sort by date
alias lm='ls -al |more' # pipe through 'more'
alias ll='ls -la' # long listing
alias lsize='ls --sort=size -lhr' # list by size
alias lsd='ls -l | grep "^d"' #list only directories
alias lalf='ls -alF'
#alias acyl='cd ~/.icons/ACYL_Icon_Theme_0.9.3/ && bash AnyColorYouLike'
alias reboot='sudo shutdown -r now'
alias shutdown='sudo shutdown -h now'
#alias setterm='export TERM=screen-256color'
#Command substitution
alias h='history | grep $1'
#alias cp='cp -v -i'
alias cp='cp -v'
#alias mv='mv -i'
if [[ -x "$(command -v trash-put)" ]]; then
alias rm='trash-put'
fi
alias which='type -all'
#alias cd..='cd ..'
#alias tmux="TERM=screen-256color tmux"
alias vim='nvim'
#alias man='vim_man'
#alias setkeyboard= "xmodmap ~/.Xmodmap"
alias turnleft="xrandr --output HDMI-1 --rotate left"
alias turnnormal="xrandr --output HDMI-1 --rotate normal"
alias wiki="xdg-open ~/knowledge/global_index/global_index.html"
alias dp="du -h --max-depth=1"
#gnome
alias gndir='~/.local/share/gnome-shell/extensions'
alias gtkparasite='GTK_MODULES=gtkparasite gnome-tweak-tool'
#yudai_cloud_foundry
alias godev='cd ~/workspace/gocode/src/github.com/'
alias rbdev='cd ~/workspace/rubycode'
alias pydev='cd ~/workspace/pycode'
#alias monit='sudo /var/vcap/bosh/bin/monit'
alias monitor_off='sudo vbetool vgastate off && sudo vbetool dpms off'
alias monitor_on='sudo vbetool vgastate off && sudo vbetool dpms on'
alias trm='transmission-remote'
alias trmadd='transmission-remote -a "$1"'
alias trmstop='pidof transmission-daemon | xargs sudo kill -9 '
alias trmstart='transmission-daemon'
alias trmrestart='pidof transmission-daemon | xargs sudo kill -9 | transmission-daemon'
#trmadd functioning for .torrent
#for f in *.torrent
#do
##transmission-remote -a "\'$f\'"
#COMMAND="transmission-remote -a '$f'"
#eval $COMMAND
#done
#secure_rm(){
#echo $1
#if [[ "$1" == "-*" ]]; then
#echo "rm=mv --> don't use -*"
#else
#mv $@ /tmp/
#fi
#}
### FUNCTIONS
function git_diff() {
git diff --no-ext-diff -w "$@" | vim -R –
}
#search string
ss(){
grep -R "$@" .
}
#search file
sf(){
#find . -type f -exec grep -H $1 {} +
find . -name "*$1*" | grep $1
}
# Easy extract
# uncompress depending on extension...
# Creates an archive from given directory
mktar() {
tar cvf "${1%%/}.tar" "${1%%/}/";
}
mktgz() {
tar cvzf "${1%%/}.tar.gz" "${1%%/}/";
}
mktbz() {
tar cvjf "${1%%/}.tar.bz2" "${1%%/}/";
}
sr(){
#define file and dir to copy
private_dir=/tmp/$USER
if [[ ! -d $private_dir ]]; then
mkdir $private_dir
fi
for var in "$@"; do
if [[ -d $var || -f $var ]]; then
current_file=$private_dir/$var
if [[ -d $current_file || -f $current_file ]]; then
#copies=$(find /tmp/cloud -name "$var*")
copies=$(ls -1vr $current_file*)
for copy in $copies; do
i=$((${#str}-1))
number="${copy:$i:1}"
number=$((${number}+1))
number=$number+1
#mv $copy "$current_file$number"
mv $copy $current_file$number
done
#mv $var $private_dir
fi
fi
done
#echo $files
#mv $files /tmp/$USER
##copy in tmp directory
#cp -r $files /tmp/
##fast remove
#rm -ifR $@;
}
extract() {
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.tar.xz) tar xvfJ "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xvf "$1" ;;
*.tbz2) tar xvjf "$1" ;;
*.tgz) tar xvzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*)
echo "'$1' cannot be extracted"
return 1
;;
esac
else
echo "'$1' is not a valid file"
return 1
fi
return 0
}
vman(){
man $1 | vim -
}
ie(){
if hash trans 2>/dev/null; then
trans {it=en} "$1"
else
echo "program not exist: install with -> google_translate_cli.sh"
fi
}
ei(){
if hash trans 2>/dev/null; then
trans {en=it} "$1"
else
echo "program not exist: install with -> google_translate_cli.sh"
fi
}
highlight() {
declare -A fg_color_map
fg_color_map[black]=30
fg_color_map[red]=31
fg_color_map[green]=32
fg_color_map[yellow]=33
fg_color_map[blue]=34
fg_color_map[magenta]=35
fg_color_map[cyan]=36
fg_c=$(echo -e "\e[1;${fg_color_map[$1]}m")
c_rs=$'\e[0m'
sed -u s"/$2/$fg_c\0$c_rs/g"
}
badass_line() {
#!/bin/bash
# Original: http://frexx.de/xterm-256-notes/
# http://frexx.de/xterm-256-notes/data/colortable16.sh
# Modified by Aaron Griffin
# and further by Kazuo Teramoto
FGNAMES=('● ●' '● ●' '● ●' '● ●' '● ●' '● ●' '● ●' '● ●')
#FGNAMES=('⚓ ⚓' '⚓ ⚓' '⚓ ⚓' '⚓ ⚓' '⚓ ⚓' '⚓ ⚓' '⚓ ⚓' '⚓ ⚓')
#FGNAMES=('☢ ☢' '☢ ☢' '☢ ☢' '☢ ☢' '☢ ☢' '☢ ☢' '☢ ☢' '☢ ☢')
green="01;38;5;40" #green
purple="01;38;5;99" #violet
lblue="01;38;5;123" #light-blue
#personalized
for b in $(seq 0 0); do
if [ "$b" -gt 0 ]; then
bg=$(($b+39))
fi
echo
for f in $(seq 0 7); do
if [[ "$f"%3 -eq 0 ]]; then
echo -en "\033[${bg}m\033["$green"m ${FGNAMES[$f]} "
echo -en "\033[${bg}m\033["$green"m ${FGNAMES[$f]} "
elif [[ "$f"%3 -eq 1 ]]; then
#statements
echo -en "\033[${bg}m\033["$purple"m ${FGNAMES[$f]} "
echo -en "\033[${bg}m\033["$purple"m ${FGNAMES[$f]} "
else
echo -en "\033[${bg}m\033["$lblue"m ${FGNAMES[$f]} "
echo -en "\033[${bg}m\033["$lblue"m ${FGNAMES[$f]} "
fi
done
echo -e "\033[0m"
echo
done
}
parse_git_branch(){
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
####
## Colorize Maven Output
####
alias maven="command mvn"
color_maven() {
local BLUE="[0;34m"
local RED="[0;31m"
local LIGHT_RED="[1;31m"
local LIGHT_GRAY="[0;37m"
local LIGHT_GREEN="[1;32m"
local LIGHT_BLUE="[1;34m"
local LIGHT_CYAN="[1;36m"
local YELLOW="[1;33m"
local WHITE="[1;37m"
local NO_COLOUR="[0m"
maven "$@" | sed \
-e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${LIGHT_GREEN}Tests run: \1$NO_COLOUR, Failures: $RED\2$NO_COLOUR, Errors: $YELLOW\3$NO_COLOUR, Skipped: $LIGHT_BLUE\4$NO_COLOUR/g" \
-e "s/\(\[\{0,1\}WARN\(ING\)\{0,1\}\]\{0,1\}.*\)/$YELLOW\1$NO_COLOUR/g" \
-e "s/\(\[ERROR\].*\)/$RED\1$NO_COLOUR/g" \
-e "s/\(\(BUILD \)\{0,1\}FAILURE.*\)/$RED\1$NO_COLOUR/g" \
-e "s/\(\(BUILD \)\{0,1\}SUCCESS.*\)/$LIGHT_GREEN\1$NO_COLOUR/g" \
-e "s/\(\[INFO\] [^-].*\)/$LIGHT_GRAY\1$NO_COLOUR/g" \
-e "s/\(\[INFO\] -.*\)/$LIGHT_GREEN\1$NO_COLOUR/g"
return $PIPESTATUS
}
alias mvn=color_maven
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'