-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_aliases.bash
More file actions
189 lines (160 loc) · 5.16 KB
/
bash_aliases.bash
File metadata and controls
189 lines (160 loc) · 5.16 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
# Inspired by:
# https://github.com/sapegin/dotfiles
# https://github.com/miripiruni/dotfiles
# https://github.com/dreadatour/dotfiles
# https://github.com/paulirish/dotfiles
# https://github.com/addyosmani/dotfiles
# Aliases #
###########
# Prompt before overwrite
alias cp='cp -i'
alias rm='rm -I'
alias mv='mv -i'
alias ln='ln -i'
# Some more ls aliases
alias ll='ls -lahF'
alias la='ls -AhF'
alias l='ll'
# tree aliaces
alias tree='tree --dirsfirst'
# Easier navigation
alias ..="cd ..;" # .. .. ..
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~"
alias -- -="cd -" # The alias is `-`, not `--`
# Helpers
alias fndf="sudo find ./ -type f -exec chmod 664 {} \;"
alias fndd="sudo find ./ -type d -exec chmod 775 {} \;"
alias sourcer="source ~/.bash_profile"
alias bashaliases="$EDITOR ~/.bash_aliases"
alias v-upgrade=" \
echo -e \"== Apt ==\\n\" && \
sudo apt update && \
apt list --upgradable && \
sudo apt upgrade && \
sudo apt dist-upgrade && \
sudo apt autoremove && \
echo -e \"== Snap ==\\n\" && \
sudo snap refresh && \
echo -e \"== Vim ==\\n\" && \
vim \"+call dein#update()\" +qall \ && \
echo -e \"== Npm ==\\n\" && \
npm install -g npm && \
npm update -g && \
npm outdated -g --depth=0 && \
echo -e \"== Basher ==\\n\" && \
basher outdated && \
alert \
"
alias open="xdg-open"
alias o="open"
alias oo="open ."
alias e="$EDITOR"
alias v="vim"
# Play sound Done!
alias alert-done="paplay /usr/share/sounds/freedesktop/stereo/complete.oga"
# 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$//'\'')"; alert-done'
# Timer
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
# Show image size
alias v-size="identify -format '%wx%h\nwidth: %wpx;\nheight: %hpx;\nwidth %wpx\nheight %hpx'"
# Show my IP
alias myip="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | awk '{print \$2}'"
# Show my distribution version
alias mydist="lsb_release -rc"
# Download file and save it with filename of remote file
alias get="curl -O"
# MySQL dump
alias md='mysqldump -h localhost -u root --skip-opt --add-locks --lock-tables --extended-insert --create-options -cq'
alias adhosts="sudo $EDITOR /etc/apache2/sites-available/`whoami`.conf"
alias edhosts="sudo $EDITOR /etc/hosts"
alias apre="sudo service apache2 restart"
alias v-nr="sudo service nginx restart"
alias v-ar="sudo service apache2 restart"
alias v-ns="sudo service apache2 stop && v-nr"
alias v-as="sudo service nginx stop && v-ar"
# SVN aliases
alias sr="svn resolved"
alias st="svn st"
alias sp="svn up"
alias stp="echo 'svn status:'; \
st; \
echo '- - - - - - - - - - - - - - - -'; \
echo 'svn update:'; \
sp"
alias stu="echo 'svn status:'; \
st; \
echo '- - - - - - - - - - - - - - - -'; \
echo 'svn update:'; \
svn merge --dry-run -r BASE:HEAD ./"
alias stm="svn log | grep -B3 merge"
alias sts="svn log | grep -B3 start"
alias sa="svn add"
alias sad="st | grep ^?"
alias sadd="st | awk '/^[?]/{ print \$2 }' | xargs svn add"
alias stc="st | grep ^C"
# Open conflicts in Netbeans
# alias stcn="st | awk '/^C/{ print \$2 }' | xargs '~/netbeans-7.2/bin/netbeans'"
# Git aliases
alias glog="git log --pretty=format:'%h %ad | [%an] %s%d' --graph --date=short"
alias ghist="git hist"
alias ghistp="ghist -p"
alias ghists="ghist --stat"
alias gs="git status"
alias ga="git add"
alias gb="git branch"
alias gba="gb -a"
alias gc="git commit"
alias gcm="gc -m"
alias gcam="gc -am"
alias gd="git diff"
alias gdc="gd --cached"
alias gco="git branch | fzf | xargs git switch"
alias gcom="gco master"
alias gcob="git switch -c "
# alias gcob="git branch -a | ipt | xargs git checkout"
alias gk="gitk --all&"
alias gg="git gui&"
alias gtree='git log --graph --full-history --all --color --pretty=format:"%x1b[33m%h%x09%x09%x1b[32m%d%x1b[0m %x1b[34m%an%x1b[0m %s" "$@"'
alias gpull="git pull "
alias gpullr="git pull --rebase "
alias gpullro="git pull --rebase origin "
alias gfo="git fetch origin "
alias gpush="git push"
alias gm="git merge "
alias gmnf="git merge --no-ff "
# npm aliases
alias npmr="npm run"
alias npms="npm start"
alias npmd="npmr deploy"
alias npmb="npmr build"
alias npmt="npmr test"
alias npml="npmr lint"
alias npmlt="npml && npmt"
alias npmi="npm i"
alias npmig="npmi -g"
alias npmid="npmi -D"
alias npmis="npmi -S"
alias npmu="npm-upgrade"
alias npmglist="npm list --global=true --depth=0"
# Update neovim
alias v-nvimupdate=" \
cd ~/work/neovim && \
gpull && \
rm -rf build && \
make clean && \
make CMAKE_BUILD_TYPE=Release && \
notify-send 'v-nvimupdate' 'install' && \
sudo make install; \
alert \
"
# Copy/Paste
# example format JSON: `pbpaste | jq | pbcopy`
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
# example: `v-port-usage 8080`
alias v-port-usage='bash -xc '\''lsof -i :$0'\'''