-
Notifications
You must be signed in to change notification settings - Fork 2
/
bash-aliases
166 lines (145 loc) · 3.84 KB
/
bash-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
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
# https://github.com/wincent/Command-T/blob/master/doc/command-t.txt#L805-L816
stty -ixon -ixoff
alias h=hexedit
alias py=python
alias ipy='ipython --pdb'
alias srvim='sort | uniq -c | sort | vim -R -'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias tmp='cd /tmp'
alias lll='ll|less'
alias json='python -mjson.tool|pygmentize -l javascript'
alias jsonl='python -mjson.tool|pygmentize -l javascript|less -R'
alias mosh='LC_ALL=en_US.UTF-8 mosh'
alias mk=make
alias mkc='make -C'
alias mc='make clean'
alias mt='make test'
alias mck='make clean && make'
# git shortcuts
alias ga='git add'
alias gap='git add -p'
alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -D'
alias gc='git commit'
alias gch='git checkout'
alias gchb='git checkout -b'
alias gchd='git checkout development'
alias gchm='git checkout master'
alias gfo='git fetch origin'
alias gm='git merge'
alias gmt='git mergetool'
alias sps='git stash && git pull -r && git stash pop'
alias grh='git reset HEAD'
alias grsh='git reset --soft HEAD~'
alias gpl='git pull'
alias gplo='git pull origin'
alias gplom='git pull origin master'
alias gplr='git pull -r'
alias gplro='git pull -r origin'
alias gplrom='git pull -r origin master'
alias gps='git push'
alias gpso='git push origin'
alias gpsom='git push origin master'
alias gr='git rebase'
alias grc='git rebase --continue'
alias gra='git rebase --abort'
alias ggrep='git grep'
alias gss='git stash save'
alias gsp='git stash pop'
pause() {
echo
read -p "$*" -t 5
}
gcam() {
git commit -am "$*" || {
pause Nothing to commit, going to --amend now.
git commit -am "$*" --amend
}
}
gcm() {
git commit -m "$*" || {
pause Nothing to commit, going to --amend now.
git commit -m "$*" --amend
}
}
# add a path to $PATH if it's not already in there and the directory exists
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1"
fi
}
# under linux we don't want to add |less to the commands, as this happens
# by default
if [ "$OS" == "Windows_NT" ]; then
alias cac='git diff --cached | less'
alias gl='git log | less'
alias gst='git status | less'
gd() {
git diff $* |less
}
gsh() {
git show $* |less
}
else
alias cac='git diff --cached'
alias gd='git diff'
alias gl='git log'
alias gsh='git show'
alias ghs=gsh
alias gs=gsh
alias gst='git status'
fi
if [ "$OS" == "Windows_NT" ]; then
# default installation paths
export GVIM="/c/ProgFiles86/Vim/vim73/gvim.exe"
alias py26='/c/Python26/python.exe'
alias putty="/c/ProgFiles86/putty.exe"
alias telnet='putty -telnet'
alias tig='/c/cygwin/bin/tig.exe'
# add python27 to the path
pathadd "/c/Python27"
vim() {
# readonly stdin
if [ -z "$*" ]; then
cat -|$GVIM -R - &
# normal usage
else
$GVIM $* &
fi
}
nrvim() {
# don't rewrite the file (that is, replace tab/spaces, remove ^M)
$GVIM -c NoRewrite $* &
}
# if /d/Git exists, then assume it's our default directory
if [ -d /d/Git ]; then
cd /d/Git
fi
fi
ftrvim() {
vim -R -c 'set ft='$1 -
}
upload() {
local sha1=$(sha1sum "$1"|cut -d' ' -f1)
local bname=$(basename "$1")
ssh skier@box.haxx.in "mkdir -p ~/public_html/$sha1"
scp "$1" "skier@box.haxx.in:~/public_html/$sha1/$bname"
echo "http://box.haxx.in/~skier/$sha1/$bname"
echo "http://box.haxx.in/~skier/$sha1/$bname" |xsel -i
}
p() {
local dir="/tmp/.secret_pastes"
mkdir -p "$dir"
cat - > "$dir/paste.txt" && upload "$dir/paste.txt"
rm -rf "$dir"
}
# paste whatever is on the clipboard
alias gp='xsel -b|p'
alias v='TERM=xterm-256color vim'
# include the autogenerated file
if [ -f ~/.bash_aliases_auto ]; then
source ~/.bash_aliases_auto
fi