-
Notifications
You must be signed in to change notification settings - Fork 5
/
bashrc-rain
74 lines (65 loc) · 1.54 KB
/
bashrc-rain
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
#!bash
[[ $- != *i* ]] && return
if [[ $DISPLAY ]]; then
. ~/.dotfiles/bash/yank.sh
fi
alias eof='IGNOREEOF=3'
alias eris='ssh -t land sudo -u emiya tmux attach'
alias gdm='sudo systemctl start gdm'
alias ip='ip -c'
alias RM='/bin/rm -I'
alias sensors='sensors -A'
alias unrm='trash --restore'
b64() { printf "%s" "$*" | base64 -w0; }
rand() { perl -e "print int rand $1"; }
rm() {
local opts=() arg path nuke=() trash=()
for arg; do
if [[ $arg == -* ]]; then
opts+=("$arg")
elif (( UID == 0 )); then
nuke+=("$arg")
elif case $(realpath -s "$arg") in
# skip remote filesystems
~/tmp/fs*) false;;
# skip junk
~/.cache/pacaur/*) false;;
~/.local/share/Trash/*) false;;
*.tmp) false;;
*/.Trash/*) false;;
.unison.*) false;;
# include $HOME
~/*) true;;
/pub/*) true;;
# include removable drives
/media/*) true;;
/mnt/*) true;;
/run/media/*) true;;
# exclude everything else elsewhere
*) false;;
esac; then
trash+=("$arg")
else
nuke+=("$arg")
fi
done
if (( ${#trash[@]} )); then
trash "${opts[@]}" -- "${trash[@]}"
fi &&
if (( ${#nuke[@]} )); then
command rm -I "${opts[@]}" -- "${nuke[@]}"
fi
}
sudo:() {
if (( UID ))
then do: sudo "$@"
else do: "$@"
fi
}
nssdb="sql:$HOME/.pki/nssdb"
fxdb() { (nssdb="$HOME/.mozilla/firefox/ov6jazas.default"; "$@"); }
thdb() { (nssdb="$HOME/.thunderbird/1xrzgg5b.default"; "$@"); }
cu() { do: certutil -d "$nssdb" "$@"; }
mu() { do: modutil -dbdir "$nssdb" "$@"; }
pu() { do: pk12util -d "$nssdb" "$@"; }
st() { do: signtool -d "$nssdb" "$@"; }