-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliasrc
129 lines (108 loc) · 3.97 KB
/
aliasrc
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
# vim: syn=sh
# User specific aliases and functions
alias jobs='jobs -l'
alias j='jobs'
alias grep='grep --color=always'
alias ag="ag --color-path 35 --color-match '1;35' --color-line-number 32"
alias view='vi -R'
alias path='echo -e ${PATH//:/\\n}'
if type nvim >/dev/null; then
alias vi=nvim
else
alias vi='vim'
fi
alias sshpass='ssh -o preferredauthentications=password'
[ "$OSTYPE" != 'darwin10.0' ] && alias w='w -u'
[ -f /Applications/MacPorts/MacVim.app/Contents/MacOS/Vim ] &&
alias gvim="/Applications/MacPorts/MacVim.app/Contents/MacOS/Vim -g"
alias g='gvim --remote-tab-silent'
#alias screen='screen-ssh-agent ; screen'
#alias fixssh=". $HOME/.screen/session-variables"
#alias s='fixssh; ssh'
# a slightly cleaner approach to what the above is doing.
# now just use the following in .screenrc:
# unsetenv SSH_AUTH_SOCK
# setenv SSH_AUTH_SOCK $HOME/.screen/ssh-auth-sock.$HOSTNAME
_ssh_auth_save() {
[ -d "$HOME/.screen/" ] || mkdir -m 700 "$HOME/.screen/";
if [ "$SSH_AUTH_SOCK" != "$HOME/.screen/ssh-auth-sock.$HOSTNAME" ] ; then
ln -sf "$SSH_AUTH_SOCK" "$HOME/.screen/ssh-auth-sock.$HOSTNAME"
fi
}
alias screen='_ssh_auth_save ; export HOSTNAME=$(hostname) ; screen'
alias tmux='_ssh_auth_save ; export HOSTNAME=$(hostname) ; tmux'
# 'ls' family
if [ "$TERM" != "dumb" ]; then
export LS_OPTIONS='--color=always'
eval `dircolors`
fi
alias ls='ls -hFv $LS_OPTIONS'
alias ll='ls -l'
alias la='ls -Al'
alias l='la'
alias lx='ls -lXB'
alias lk='ls -lSr'
alias lc='ls -lcr'
alias lu='ls -lur'
alias lt='ls -ltr'
alias tree='tree --dirsfirst -FCI .svn -I .git'
# hex dump a file
alias hd='od -Ax -tx1z -v'
alias realpath='readlink -f'
alias cmdstat="history | awk {'print \$2'} | sort | uniq -c | sort -k1 -rn | head"
#alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde --read-functions'
# number base conversions
alias d2h="perl -e 'printf qq|%X\n|, int( shift )'"
alias d2o="perl -e 'printf qq|%o\n|, int( shift )'"
alias d2b="perl -e 'printf qq|%b\n|, int( shift )'"
alias h2d="perl -e 'printf qq|%d\n|, hex( shift )'"
alias h2o="perl -e 'printf qq|%o\n|, hex( shift )'"
alias h2b="perl -e 'printf qq|%b\n|, hex( shift )'"
alias o2h="perl -e 'printf qq|%X\n|, oct( shift )'"
alias o2d="perl -e 'printf qq|%d\n|, oct( shift )'"
alias o2b="perl -e 'printf qq|%b\n|, oct( shift )'"
psg () { ps aux | egrep "$1|%CPU" | grep -v grep; }
# Misc.
ff () { find . -type f -iname '*'$*'*' -ls ; }
fe () { find . -type f -iname '*'$1'*' -exec "${2:-file}" {} \; ; }
swap () { local TMPFILE="tmp.$$"; mv "$1" $TMPFILE; mv "$2" "$1"; mv $TMPFILE "$2"; }
md () { mkdir -p $1 && cd $1; }
lll () { ll $* | less; }
unixdate () { echo `perl -MHTTP::Date -e 'print @ARGV?$ARGV[0]=~/^\d+$/?scalar localtime($ARGV[0]):str2time(join " ",@ARGV):time' ${*}`; }
cssmin () {
cat $1 | sed -e '
s/^[ \t]*//g; # remove leading space
s/[ \t]*$//g; # remove trailing space
s/\([:{;,]\) /\1/g; # remove space after a colon, brace, semicolon, or comma
s/ {/{/g; # remove space before a brace
s/\/\*.*\*\///g; # remove comments
/^$/d # remove blank lines
' | sed -e :a -e '$!N; s/\n\(.\)/\1/; ta # remove all newlines
' > $2;
}
ex () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2|*.tbz2) tar xjf $1 ;;
*.tar.gz|*.tgz) tar xzf $1 ;;
*.tar) tar xf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
function calc() { echo "$*" | bc; }
#tailor 'less'
alias more='less'
export PAGER=less
#export LESSCHARSET='latin1'
export LESSOPEN='| lesspipe.sh %s'
export LESS='-i -w -z-4 -g -M -X -F -R -P%t?f%f :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-...'
function gi() { curl http://www.gitignore.io/api/\$@ ;}