-
Notifications
You must be signed in to change notification settings - Fork 72
/
.bashrc
267 lines (225 loc) · 7.29 KB
/
.bashrc
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#======================================================================#
# .bashrc
# Fichero de opciones del shell bash
#
# Electro7
# 23 sep 2019
# Versión común - WSL, debian y archlinux
#======================================================================#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
#----------------------------------------------------------------------#
# Prompt
#----------------------------------------------------------------------#
# Título para las ventanas de consola en la X
TW_TITLE='\[\e]0;\h : \s (\w)\a\]'
# Añade retorno de carro y el cambio del titulo de la ventana al P1 actual
function __promptadd
{
local col_n="\[\033[0m\]" # Reset
local col_u="\[\033[1;36m\]" # User > cyan
[[ "$UID" = "0" ]] && col_u="\[\033[1;31m\]" # Root > red
PS1="$TW_TITLE$PS1\n${col_u} \\$ ${col_n}"
}
# Prompt a traves de promptline.vim
# Es un plugin de VIM para crear un prompt con simbolos powerline.
# Entrar en vim y hacer un :PromptlineSnapShot ~/.shell_prompt.sh
function prompt_line
{
source ~/bin/prompt_powerline.sh
PROMPT_COMMAND="$PROMPT_COMMAND; __promptadd;"
}
# Prompt "normal" sin carácteres raros
function prompt_term
{
# Mi chequeo de git propio
source ~/bin/prompt_e7.sh
}
# Selección de prompt según el tipo de terminal
case "$TERM" in
rxvt*)
prompt_line
;;
*)
prompt_term
;;
esac
#----------------------------------------------------------------------#
# Colores
#----------------------------------------------------------------------#
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
export LS_OPTIONS='--color=auto'
alias l='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l -N -F'
alias ls='ls $LS_OPTIONS -A -N -hF'
fi
alias lsmp3='ls -1 --indicator-style=none *.mp3'
alias lsepub='ls -1 -R --indicator-style=none | grep epub'
export GREP_COLOR="1;31"
alias grep='grep --color=auto'
export LESS="-R"
export PAGER="most"
#----------------------------------------------------------------------#
# PATH
#----------------------------------------------------------------------#
export PATH="$PATH:$HOME/bin"
#----------------------------------------------------------------------#
# Variables variadas
#----------------------------------------------------------------------#
# Por defecto.
export EDITOR="vim"
export BROWSER="firefox"
#export QT_STYLE_OVERRIDE=GTK
export QT_QPA_PLATFORMTHEME=qt5ct
export QT_AUTO_SCREEN_SCALE_FACTOR=0
#----------------------------------------------------------------------#
# Alias
#----------------------------------------------------------------------#
# Alias WSL
if [[ $(pgrep wsl) -gt 0 ]]; then
alias start="/mnt/c/Windows/System32/cmd.exe /c "start""
alias s="start"
alias gv="start gvim.exe"
fi
# Alias contra borrados accidentales.
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Alias del shell
alias h='history'
alias v='vim'
alias vi='vim'
alias j="jobs -l"
alias psl='ps -aux | less'
alias ..='cd ..'
alias 'cd..'='cd ..'
alias df="df -h"
alias more='less'
alias du='du -h'
alias rs='rsync -W -ahvzi --progress'
# Alias para el su (root)
alias reboot="sudo /sbin/reboot"
alias halt="sudo /sbin/poweroff"
alias poweroff="sudo /sbin/poweroff"
alias pacman="sudo pacman"
alias paclean="sudo pacman -S --clean --clean"
alias dpkg="sudo dpkg"
# Alias del git
alias gia="git add"
alias gcm="git commit -a -m"
alias gs="git status"
alias gp="git push"
alias gg="git pull"
alias gd="git diff"
# Mis chuletas
alias chuleta="vim ~/.vim/doc/chuletario.txt"
alias todo="vim ~/work/ToDo.txt"
# Cambio colores de terminal
alias col_dark="sh ~/.config/termcolours/dark.sh"
alias col_light="sh ~/.config/termcolours/light.sh"
alias col_default="sh ~/.config/termcolours/default.sh"
# Wifi on/off
alias wifi_on="sudo netctl start"
alias wifi_off="sudo netctl stop"
alias wifi_status="iw dev wlan0 info"
alias wifi_menu="wifi-menu"
# App varias
alias mldonkey="mldonkey -stdout -verbosity verb"
alias netload="speedometer -r eth0 -t eth0"
alias ko="export DISPLAY=:0.0; kodi &"
alias vbox="export DISPLAY=:0.0; virtualbox &"
alias vbox_start="export DISPLAY=:0.0; VBoxManage startvm"
alias vbox_ctrl="VBoxManage controlvm"
alias vbox_ls="VBoxManage list vms"
# SSH
alias pi="ssh electro7@pi"
alias pi_work="ssh electro7@pi"
#alias pi_work="ssh tunelia@pi_work"
alias nexus="ssh electro7@nexus"
alias casiopea="ssh electro7@casiopea"
#----------------------------------------------------------------------#
# Funiones propias
#----------------------------------------------------------------------#
# Cambiar a directorio obras
cdc() {
cd $(find /mnt/d/work/obras -maxdepth 3 -type d -name *$1* | tail -n 1)
}
# Arrancar y parar máquinas vituales de vbox
vbox_on() {
VBoxManage startvm $1 --type headless
}
vbox_off() {
VBoxManage controlvm $1 savestate
}
#----------------------------------------------------------------------#
# OTROS
#----------------------------------------------------------------------#
# Auto-completion
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
source /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
source /etc/bash_completion
fi
fi
# Man coloreador - hay que instalar less
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjvf $1 ;;
*.tar.gz) tar xzvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xjvf $1 ;;
*.tgz) tar xzvf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Para que a los VT100 no se les fastidie el terminal con los colores
if [ $TERM = vt100 ]; then
alias ls='ls -F --color=never';
fi
# Check umask
if [[ $(umask) != "0022" ]]; then umask 0022; fi
#----------------------------------------------------------------------#
# Jarvis
#----------------------------------------------------------------------#
export SYS="Debian"
#----------------------------------------------------------------------#
# SSH KEY
#----------------------------------------------------------------------#
# Borra temporal si existe
if [ `ps -ef | grep ssh-agent | grep -v grep | wc -l` -eq 0 ]; then
rm -f /tmp/ssh-agent*
fi
# attempt to connect to a running agent, sharing over sessions (putty)
check-ssh-agent() {
[ -S "$SSH_AUTH_SOCK" ] && { ssh-add -l >& /dev/null || [ $? -ne 2 ]; }
}
check-ssh-agent || export SSH_AUTH_SOCK=/tmp/ssh-agent.sock_$USER
check-ssh-agent || eval "$(ssh-agent -s -a /tmp/ssh-agent.sock_$USER)" > /dev/null
#Add identities if not exist
if [[ -n $(ssh-add -l | grep 'The agent has no identities') ]] ; then
ssh-add 2> /dev/null
fi
# vim: ts=2:sw=2: