-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc.arch
218 lines (185 loc) · 6.04 KB
/
.bashrc.arch
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
#
# ~/.bashrc
#
#
# Lazy Alias
#
alias ls='ls --color=auto'
alias ll="ls -la --color -h --group-directories-first"
alias restartnetwork="sudo systemctl restart systemd-networkd";
alias montar="sudo mount -av";
alias portslisting="sudo netstat -tulpn";
alias clipboard='xclip -sel clip'
alias docker_ip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'"
alias refresh="source ~/.bashrc"
alias editbashrc="vim ~/.bashrc"
alias -- -='cd -' # type - to "cd -"
#
# Apps Alias
#
alias hidemouse="nohup unclutter -display :0.0 -idle 3 &"
#
# Fix Alias
#
alias fixvagrant_inicialize="sudo modprobe vboxdrv";
alias fixnfs="systemctl start rpcbind.service && systemctl start nfs-server.service"
alias fixwatchcss="echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p";
alias fixdropbox="echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p";
alias fixteclado="sudo setxkbmap -model abnt2 -layout br -variant abnt2";
#
# Pacman Alias
#
alias upgrade="yaourt -Syua";
alias remove="sudo pacman -Rs"
alias cleanpacman="pacman -Qtdq > /dev/null && sudo pacman -Rns \$(pacman -Qtdq | sed -e ':a;N;$!ba;s/\n/ /g')";
alias optimizepacman="sudo sudo pacman -Sc && sudo pacman-optimize && cleanpacman";
alias cleanmemory="sync && echo 3 | sudo tee /proc/sys/vm/drop_caches";
#
# Git alias
#
alias changesgit="git diff --name-status -r"
alias gdiff="git diff --stat -r"
alias ghead="git show -s --pretty='tformat:%h, %s, %ad' --date=short"
alias gl="git log --color --graph --pretty=format:'%Credbold%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gb="git branch -v"
alias g="git status -sb"
alias gc="git commit"
alias ga="git add"
alias gpl="git pull"
alias gps="git push"
alias changesgit="git diff --name-status -r"
alias rank="shortlog -sn --no-merges"
#Use it with the command. eg: git co
alias co="checkout"; # Checkout a branch
alias cob="git checkout -b"; # Checkout a new not yet existing branch
alias cor="git checkout -"; # Go back to the last branch
alias gba="git branch -a"; # List both remote-tracking branches and local branches.
alias gbd="git branch -d"; # Delete a branch only if it has been merged
alias gdc="git diff --cached"; # Display the staged changes
alias gap="git add -p"; # See the changes before adding
#
# Composer shortcut
#
alias composer-dp="composer show -i"; # It shows project's dependency
#
# Update command others (python,node)
#
alias upgradeothers="sudo pip-review --local --interactive && npm-check -gu";
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# I dunno know...
PS1='[\u@\h \W]\$ '
# enable thefuck command. Funny command
eval "$(thefuck --alias fuck)"
#
# Powerline
#
if [ -f /usr/lib/python3.5/site-packages/powerline/bindings/bash/powerline.sh ]; then
source /usr/lib/python3.5/site-packages/powerline/bindings/bash/powerline.sh
fi
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && . /usr/share/bash-completion/bash_completion
# Append to the history file, don't overwrite it
shopt -s histappend
# Save multi-line commands as one command
shopt -s cmdhist
# Append cd command when a directory's name is typed
shopt -s autocd
# autocorrect minor spelling errors in directory name (both)
shopt -s dirspell
shopt -s cdspell
#
# Better Bash History
#
# Huge history. Doesn't appear to slow things down, so why not?
HISTSIZE=500000
HISTFILESIZE=100000
# Avoid duplicate entries
HISTCONTROL="erasedups:ignoreboth"
# Don't record some commands
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history"
# Useful timestamp format
HISTTIMEFORMAT='%F %T '
###################################
# Adds "projeto" path to always be possible to jump to a particular project, whenever I want
CDPATH=".:~/projeto"
# workaround
fixinicial() {
# layout teclado
sudo setxkbmap -model abnt2 -layout br -variant abnt2
# habilitar virtualização
sudo modprobe vboxdrv
# montar servidores arca
sudo mount -av
# habilitar ip interno fixo
sudo modprobe vboxnetflt
# erro de gui, não estava iniciando, resolvido após rodar isso
sudo modprobe vboxnetadp
}
# workaround
fixvagrant() {
# habilitar virtualização
sudo modprobe vboxdrv
# habilitar ip interno fixo
sudo modprobe vboxnetflt
# erro de gui, não estava iniciando, resolvido após rodar isso
sudo modprobe vboxnetadp
}
updatecontaineredirectoryx() {
# gets container IP
IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' edirectoryx2)
# gets older IP saved in a file
OLD_IP=$(cat ~/old_ip_edirectoryx)
# changes IPs in hosts file
sudo sed -i -e "s/$OLD_IP/$IP/g" /etc/hosts
# copy new IP to file
echo $IP > ~/old_ip_edirectoryx
}
updatecontainerdb() {
# gets container IP
IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' db)
# gets older IP saved in a file
OLD_IP=$(cat ~/old_ip_db)
# changes IPs in hosts file
sudo sed -i -e "s/$OLD_IP/$IP/g" /etc/hosts
# copy new IP to file
echo $IP > ~/old_ip_db
}
updateallcontainers() {
# updates IPs from projects
updatecontainerdb && updatecontaineredirectoryx
}
# explain commands
explain () {
if [ "$#" -eq 0 ]; then
while read -p "Command: " cmd; do
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd"
done
echo "Bye!"
elif [ "$#" -eq 1 ]; then
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1"
else
echo "Usage"
echo "explain interactive mode."
echo "explain 'cmd -o | ...' one quoted command to explain it."
fi
}
#
# Export Functions
#
export -f fixinicial
export -f fixvagrant
export -f updatecontaineredirectoryx
export -f updatecontainerdb
export -f updateallcontainers
export -f explain
#
# Export PATH
#
export PATH=/home/faustino/.gem/ruby/2.2.0/bin:$PATH
#export python=/usr/bin/python2
export PATH=~/bin:$PATH
export DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4"
if [ -d "$HOME/opt/node-webkit" ]; then
PATH="$PATH:$HOME/opt/node-webkit"
fi
bind Space:magic-space