-
Notifications
You must be signed in to change notification settings - Fork 3
/
aliases
136 lines (118 loc) · 3.39 KB
/
aliases
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
###################### Shortcuts
alias ..='cd ..'
alias ...='cd ../..'
alias ~='cd ~'
alias ll="ls -l"
alias la="ll -a"
alias df="df -h"
alias h="history"
alias g="git"
alias time="date;time"
alias vimupdate="vim +BundleInstall! +BundleClean +q"
alias empty="cat /dev/null > "
## Server (Debian) Specific
alias restartapache="sudo /etc/init.d/apache2 restart"
alias restartmysql="sudo /etc/init.d/mysql restart"
alias install="sudo apt-get install"
gitempty () {
mkdir -p $1
echo "# Ignore everything in this directory" > $1/.gitignore
echo "*" >> $1/.gitignore
echo "# Except this file" >> $1/.gitignore
echo "!.gitignore" >> $1/.gitignore
git add $1/.gitignore
}
###################### Gadgets
alias ip="curl -s https://checkip.dyndns.com/ | sed 's/[^0-9\.]//g'"
alias localip="ipconfig getifaddr en1"
alias genpass="LC_ALL=C tr -dc '[:alnum:]' < /dev/urandom | fold -w40 | head -n1"
alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"' #Share current dir over localhost:8000
u2d () {
# Unix timestamp to date
if [[ $OSTYPE == 'darwin10.0' ]]; then
date -r $1
else
date -ud \"1970-01-01 + $1 seconds\"
fi
}
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $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 "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
fars () {
if [ $1 ] ; then
if [ $2 ] ; then
grep -r $1 .
echo "sed -i.backup -e 's/$1/$2/' \`grep -lr $1 .\`"
else
echo "'$2' is not a valid string! fars oldstring newstring"
fi
else
echo "'$1' is not a valid string! fars oldstring newstring"
fi
}
###################### Processes
psx () {
if [ $1 ] ; then
ps aux | grep $1 | grep -v grep
else
echo "!! Need name to grep for"
fi
}
psxk () {
psx $1
kill -9 `ps auxw | grep -i $1 | awk '{print $2}'`
}
###################### SSH
copykey () {
if [ -f ~/.ssh/id_rsa.pub ] ; then
echo "Key exists..."
else
echo "Key doesnt exist, creating..."
ssh-keygen -f ~/.ssh/id_rsa -b 4096
fi
if [ $1 ] ; then
echo "Transferring..."
cat ~/.ssh/id_rsa.pub | ssh $@ "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && cat - >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && chmod 700 ~/.ssh"
echo "Done"
else
echo "'$1' is not a valid server! Usage: copykey user@hostname"
fi
}
###################### SVN
svn-rv-ci () {
if [ $1 ] ; then
if [ $2 ] ; then
svn cat -r $1 $2 > $2
else
echo "'$2' is not a valid file"
fi
else
echo "'$1' is not a valid revision number"
fi
}
svnulog () {
svn log -v $1 | sed -n '/\| $2 \|/,/-----\$/ p'
}
svnstf () {
svn status | grep "^$1" | awk '{ print $2 }'
}
alias svncf="svnstf C"
alias svnurl="svn info | grep URL | awk -F': ' '{ print \$2 }'"
alias svnver="change-svn-wc-format.py"