-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.bashrc
350 lines (316 loc) · 10.1 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
alias vi="vim"
alias ll="ls -asl -F -T 0 -b -H -1 --color=always"
alias l="ls -CF"
alias less="less -rM"
alias cp="cp -p"
alias df="df -T"
alias du="du -h -c"
alias mutt="neomutt"
alias grep="grep --color"
alias bash="/bin/bash --login"
alias slrn="slrn --kill-log $HOME/.slrn/kill_log.log"
alias startx="startx -nolisten tcp -deferglyphs 16"
alias gmail="mutt -f imaps://[email protected]:993"
alias gmail2="mutt -f imaps://[email protected]:993"
alias gmail3="mutt -f imaps://[email protected]:993"
alias bajkal="mutt -f imap://in.virgilio.it"
alias yahoo='mutt -f imaps://[email protected]:993'
alias papersounds="mutt -f imaps://[email protected]@mail.papersounds.eu:993"
alias nespressoguide="mutt -f imaps://[email protected]@mail.nespressoguide.com:993"
alias pop3msn="mutt -f pops://[email protected]@pop3.live.com:995"
alias alsamixer="alsamixer -V all"
alias dpmsoff="xset -dpms && xset s off"
alias dpmson="xset +dpms && xset s on"
alias dvdburn="growisofs -Z /dev/cdrom -J -R"
alias httpsharedir="python -m http.server 8001 --bind 127.0.0.1"
alias acestreamengine="acestreamengine --live-disk-cache-size 10000"
# Mplayer using 2 threads/cpu by default
# disabled because it make playing dvds impossible
#alias mplayer="mplayer -lavdopts fast:threads=2"
alias orphans="pacman -Qtdq" # packages not required by any other
alias expliciti="pacman -Qetq" # explicitly installed packages not required by any other
# Rsync alias to sync between laptop and desktop over ssh
alias ssrsync="rsync -av -C --progress --inplace --delete-after -e 'ssh -p 8898'"
# Two openssl aliases to encode/decode files
alias ssl_enc="openssl aes-256-cbc -salt"
alias ssl_dec="openssl aes-256-cbc -d"
# Ettercap ARP spoofing ;)
alias etterspoof="sudo ettercap -T -M arp:remote -P autoadd /192.168.1.3/ /192.168.1.1/"
# Show user declared functions
alias show_funcs="declare -F | grep -v _"
# Disable/enable speakers
alias speakeron="amixer set Speaker unmute"
alias speakeroff="amixer set Speaker mute"
# Correctly connect over ssh (kitty terminal fix)
alias kittyssh="kitty +kitten ssh"
# Reboot, one time only, on Windows
alias backtowindows="sudo bootctl set-oneshot auto-windows"
# top 20 most used commands
toptwenty() {
history | awk '{if ($4 == "sudo") {print $5} else {print $4}}' | \
awk 'BEGIN {FS ="|"} {print $1}' \
| grep -v toptwenty | sort | uniq -c | sort -rn | head -20
}
startX() {
if [ -z "$XDG_VTNR" ]; then
startx -nolisten tcp -deferglyphs 16
else
startx -nolisten tcp -deferglyphs 16 vt$XDG_VTNR
fi
disown
logout
}
# Pngtojpeg - converts each png in the current directory in jpeg
pngtojpeg() {
for p in *.[pP][nN][gG] ; do
convert "$p" "${p%.*}.jpg" ;
done
}
vboxbuild() {
sudo dkms install vboxhost/$1 -k $(uname -r)/$(uname -m)
}
gitgrep() {
git rev-list --all | ( while read revision; do
git grep -F $1 $revision;
done
)
}
# Quickly mount/umount an Android phone
phone() {
if [[ $1 == 'mount' ]]; then
mkdir -p phone
go-mtpfs -o allow_other phone
if [ $? -eq 0 ]; then
echo "Your phone has been successfully mounted"
else
echo "Something went wrong, the phone couldn't be mounted"
fi
elif [[ $1 == 'umount' ]]; then
fusermount -u phone
if [ $? -eq 0 ]; then
if [ -d phone ]; then
rm -rf phone/
fi
else
echo "Couldn't unmount the phone"
fi
else
echo "Use phone (mount|umount) to mount or unmount your phone"
return 1
fi
}
forecast_me() {
curl -S http://wttr.in/$1
}
ccurrencies() {
curl eur.rate.sx/?n=20
}
have_a_rainbow() {
yes "$(seq 231 -1 16)" | while read i; do printf "\x1b[48;5;${i}m\n"; sleep .02; done
}
# Cd with context (thanks to @smllmp)
c() {
cd "$1";
ls -ltra | tail -n 25;
echo " ";
pwd;
}
# output local directories, relative to . , that suck up the most
# diskspace
wheredidallthespacego() {
sudo du -h $1 | grep -P '^[0-9\.]+[MGT]'
}
# optimize and resize to a given size an image
# Usage: resizeimage imgpath size pathtosavetheimg
resizeimages() {
mogrify -path $3 -filter Triangle -define filter:support=2 -thumbnail $2 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 62 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB "$1"
}
# Play Youtube videos while downloading. Requires youtube-dl and mpv (or MPlayer)
youplay() {
youtube-dl --geo-bypass -o - $1 | mpv -
}
# Easily mark and jump in the filesystem
# From
# http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
export MARKPATH=$HOME/.marks
function mjump() {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No suck mark: $1"
}
function mmark() {
mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
}
function munmark() {
rm -i "$MARKPATH/$1"
}
function mmarks() {
\ls -l "$MARKPATH" | grep -v '^total' | awk '{printf "%-15s -> %s\n", $9,$11}' && echo
}
n ()
{
# Block nesting of nnn in subshells
if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
echo "nnn is already running"
return
fi
# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set)
# To cd on quit only on ^G, remove the "export" as in:
# NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# NOTE: NNN_TMPFILE is fixed, should not be modified
export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
# stty start undef
# stty stop undef
# stty lwrap undef
# stty lnext undef
nnn "$@"
if [ -f "$NNN_TMPFILE" ]; then
. "$NNN_TMPFILE"
rm -f "$NNN_TMPFILE" > /dev/null
fi
}
# Plugins for nnn
export NNN_PLUG='p:preview-tui'
# Fifo for nnn
export NNN_FIFO=/tmp/nnn.fifo
# Bookmarks for nnn
export NNN_BMS="h:${HOME};p:/media/private/;i:/mnt/documents/c/Tempstuff/instagram"
# Colors for nnn
export NNN_COLORS="#163e7b"
# Archives to handle in nnn
export NNN_ARCHIVE="\\.(7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)$"
# No one should read/write/execute my files by default
#umask 0077
# Bash Colors
bblack="\033[0;30m" # black
bred="\033[0;31m" # red
bRed="\033[1;31m" # bold red
bgreen="\033[0;32m" # green
bGreen="\033[1;32m" # bold green
byellow="\033[0;33m" # yellow
bYellow="\033[1;33m" # bold yellow
bblue="\033[0;34m" # blue
bBlue="\033[1;34m" # bold blue
bmagenta="\033[0;35m" # magenta
bMagenta="\033[1;35m" # bold magenta
bcyan="\033[0;36m" # cyan
bCyan="\033[1;36m" # bold cyan
bwhite="\033[0;37m" # white
bnc="\033[0;0m" # no color
undblack="\033[4;30m" # black underlined
undred="\033[4;31m" # red underlined
undgreen="\033[4;32m" # green underlined
undyellow="\033[4;33m" # yellow underlined
undblue="\033[4;34m" # blue underlined
undpurple="\033[4;35m" # purple underlined
undcyan="\033[4;36m" # cyan underlined
undwhite="\033[4;37m" # white underlined
# background colors
bgblack="\033[40m"
bgred="\033[41m"
bggreen="\033[42m"
bgyellow="\033[43m"
bgblue="\033[44m"
bgmagenta="\033[45m"
bgcyan="\033[46m"
bgwhite="\033[47m"
txtreset="\033[0m" # text reset
export PATH="/usr/local/bin:/opt/android-sdk/platform-tools/:/usr/lib/go/bin/:$HOME/.go/bin/:$HOME/.local/bin/:$PATH"
# Variables for the git prompt
GIT_PS1_SHOWDIRTYSTATE="1"
GIT_PS1_SHOWUNTRACKEDFILES="1"
# Bash Prompts
if [ "$TERM" = "linux" ]
then
PS1="${bYellow}\[[${bnc}\u@\H ${bYellow}\W${bYellow}]\]$ ${bnc}"
else
export TITLEBAR='\[\e]0;\u $BASH_COMMAND\007'
if [[ `whoami` == "root" ]]; then
PS1="${bYellow}«${bnc} \$(date +%d/%m/%Y) ${bYellow}»${bnc} \h${bYellow}:${bnc}\w \n${bred} >: ${bnc}"
else
PS1="${bYellow}«${bnc} \$(date +%d/%m/%Y) ${bYellow}»${bnc} \h${bYellow}:${bnc}\w \n >: "
fi
fi
export BROWSER="firefox"
export EDITOR="vim"
export MAIL="$HOME/Maildir/"
export SLANG_EDITOR='vim'
export NNTPSERVER='news.tin.it'
export MAILCHECK=600000000000 # I don't really need a shell mailcheck....
export PYTHONSTARTUP="$HOME/.pythonrc.py"
export GOPATH="$HOME/.go/"
export GOBIN="$HOME/.go/bin/"
# use less with utf8
export LESSCHARSET="utf-8"
export DATE=`date +%G_%m_%d`
# set the size of the bash history
export HISTSIZE=2000
# add date and time to history elements
export HISTTIMEFORMAT='%F %T '
export HISTCONTROL=ignoreboth # no doubles in bash_history
# set ls colors
# di=directories, fi=files, ln=symbolic links, pi=fifo, so=sockets,
# bd=block files, cd=character files, or=symbolic orphaned links,
# mi=non-existent files that have a symbolic link to them,
# ex=executables
#
# Color numbers:
# 0 (default)
# 1 (bold)
# 4 (underlined)
# 5 (flashing)
# 7 (reverse field)
# 31 (red)
# 32 (green)
# 33 (orange)
# 34 (blue)
# 35 (purple)
# 36 (cyan)
# 37 (grey)
# 40 (black background)
# 41 (red background)
# 42 (green background)
# 43 (orange background)
# 44 (blue background)
# 45 (purple background)
# 46 (cyan background)
# 47 (grey background)
# 90 (dark grey)
# 91 (light red)
# 92 (light green)
# 93 (yellow)
# 94 (light blue)
# 95 (light purple)
# 96 (turquoise)
# 100 (dark grey background)
# 101 (light red background)
# 102 (light green background)
# 103 (yellow background)
# 104 (light blue background)
# 105 (light purple background)
# 106 (turquoise background
#export LS_COLORS="di=1:fi=0:ln=95:pi=93:so=36:bd=96:cd=96:or=95,101:mi=95,101:ex=94"
eval $(dircolors -b ~/.dir_colors/dircolors.ansi-universal)
# to improve firefox responsiveness
export MOZ_DISABLE_PANGO=1
# Make Qt use Gtk2 themes
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
# Use nvidia VDPAU backend
#export VDPAU_DRIVER=nvidia
#export LIBVA_DRIVER_NAME=nvidia
# Check terminal size
shopt -s checkwinsize
# autocorrect cd typos
shopt -s cdspell
# auto completion
source /usr/share/bash-completion/completions/git
#source <(kitty + complete setup bash)
# git prompt
#source /usr/share/git/git-prompt.sh
# bash-git-prompt settings
# (https://github.com/magicmonty/bash-git-prompt)
GIT_PROMPT_ONLY_IN_REPO=1 # show prompt only in git repos
GIT_PROMPT_SHOW_UPSTREAM=1 # show upstream branch
GIT_PROMPT_THEME="Solarized" # theme
#GIT_PROMPT_START="${bBlue}[${bnc}\h${bBlue}:${bnc}\w${bBlue}]${bnc}"
source ~/.bash-git-prompt/gitprompt.sh
clear # clear the screen if something is on it