-
Notifications
You must be signed in to change notification settings - Fork 0
/
.commonrc
199 lines (177 loc) · 4.45 KB
/
.commonrc
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
#!$SHELL
# shellcheck shell=sh
export EDITOR="emacsclient -c"
export LC_ALL=
export LC_COLLATE="C"
export FZF_DEFAULT_COMMAND='rg --files --hidden --follow'
export GOPATH="$HOME/.go"
if [ "${LESS#*-iRs}" = "$LESS" ]; then
export LESS="$LESS -iRs"
fi
#PATH handling
pathmunge() {
case ":${PATH}:" in
*:"$1":*) ;;
*)
if [ "$2" = "after" ]; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
;;
esac
}
is_exe() {
hash "$1" 2>/dev/null
}
for dir in ".local/share" ".local" ".go" ".roswell" ".cargo"; do
if [ "${PATH#*"$HOME"/"${dir}"/bin}" = "$PATH" ] && [ -d "$HOME/${dir}/bin" ]; then
pathmunge "$HOME/${dir}/bin" after
fi
done
if is_exe nvim; then
alias vi='nvim'
alias vim='nvim'
else
alias vi='vim'
fi
alias ls='ls --color=auto'
alias grep='grep --colour=auto'
alias x='startx'
alias ta='tmux a -d > /dev/null || tmux'
alias taa='tmux a > /dev/null || tmux'
alias undb='killall Xephyr ; export DISPLAY=":0.0" PS1=${PS1##*AWDB }'
alias mtr='mtr --curses'
alias myip='curl icanhazip.com'
alias wifi='sudo wifi-menu'
alias o='xdg-open'
alias om='nice -n20 ionice -c3 offlineimap; nice -n20 ionice -c3 mu index'
alias t=task
alias to=taskopen
alias ix='curl -F "f:1=<-" ix.io'
alias gea="guix environment --ad-hoc"
alias sudo="sudo " # Lets me use other aliases via sudo
alias qr="qrencode -tutf8"
#Games :)
#alias megarace='dosbox -conf ~/dosbox/MEGARACE/dosbox-0.74.conf -c "mount c ~/dosbox" -c "mount e ~/dosbox/megarace_cd" -c c: -c "cd MEGARACE" MEGARACE.BAT'
#alias engage=""
#play -n -c1 synth whitenoise lowpass -1 120 lowpass -1 120 lowpass -1 120 gain +14
#play -n -c1 synth whitenoise band 100 20 compand .3,.8 -1,-10 gain +20
#play -n -c1 synth whitenoise band -n 100 20 band -n 50 20 gain +25 fade h 1 864000 1
# Ensure GPG prompts here
GPG_TTY=$(tty)
export GPG_TTY
# Keychain
# Disabling complaint of EUID being non-POSIX. It's just a speedup.
# shellcheck disable=SC3028
if [ "$EUID" -gt 1 ] || [ "$(id -u)" -gt 1 ]; then
if [ -f "$(command -v keychain)" ]; then
ssh_keys=$(find ~/.ssh -name id_\* -and \! -name \*.pub)
#gpg_keys=$(gpg -K | grep 'sec ' | awk '{ print $2 }' | cut -d'/' -f 2)
gpg_keys=""
eval "$(keychain --eval -q "$ssh_keys" "$gpg_keys")"
unset gpg_keys
unset ssh_keys
fi
fi
# Python environ handling
if is_exe direnv; then
if [ -z ${ZSH_NAME+x} ]; then
eval "$(direnv hook bash)"
elif [ -z ${BASH+x} ]; then
eval "$(direnv hook zsh)"
fi
elif is_exe pyenv; then
echo "Using pyenv."
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
elif is_exe virtualenvwrapper.sh; then
echo "Using virtualenvwrapper."
export WORKON_HOME=~/.virtualenvs
# shellcheck source=/dev/null
. "$(command -v virtualenvwrapper.sh)"
fi
# fzf & fd
if is_exe fzf && is_exe fd; then
export FZF_DEFAULT_COMMAND="fd . $HOME"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd -t d . $HOME"
fi
d() {
for word in "$@"; do
curl dict://dict.org/d:"${word}" 2>/dev/null | less -FX
done
}
urxvtcd() {
urxvtc "$@"
if [ $? -eq 2 ]; then
urxvtd -q -o -f
urxvtc "$@"
fi
}
toweb() {
if [ -n "$1" ]; then
rsync -SHPcavy "$@" igal:/var/www/files/ &&
for x in "$@"; do
echo "http://files.pflug.io/$(basename "${x}" | sed 's/ /%20/g')"
done
else
echo "What should be sent?"
fi
}
opng() {
if [ -n "$1" ]; then
if is_exe parallel; then
is_exe advpng >/dev/null && parallel advpng -z4 ::: "$@"
is_exe ect >/dev/null && parallel ect --strict -9 ::: "$@"
is_exe optipng >/dev/null && parallel optipng -o7 -zw32k -p ::: "$@"
else
is_exe advpng >/dev/null && advpng -z4 "$@"
is_exe ect >/dev/null && ect --strict -9 "$@"
is_exe optipng >/dev/null && optipng -o7 -zw32k -p "$@"
fi
fi
}
wp() {
if [ -n "$1" ]; then
for img in "$@"; do
if [ -z "${img#*.png}" ]; then
opng "$img"
elif [ -z "${img#*.jpg}" ]; then
jpegoptim "$img"
fi
mv -i "$@" ~/wallpapers
done
fi
}
waitfor() {
while pgrep -f "$1" >/dev/null; do
sleep 30
done
}
sudofor() {
while pgrep -f "$1" >/dev/null; do
sudo -v
sleep 4m
done
}
setproxy() {
export HTTP_PROXY="$1"
export HTTPS_PROXY="$HTTP_PROXY"
export FTP_PROXY="$HTTP_PROXY"
export SOCKS_PROXY="$HTTP_PROXY"
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTP_PROXY"
export ftp_proxy="$HTTP_PROXY"
export socks_proxy="$HTTP_PROXY"
}
cpterminfo() {
infocmp | ssh "$1" "cat | tic -x -"
}
gear() {
guix shell "$1" -- "$@"
}
if [ -e ~/.commonrc_local ]; then
# shellcheck source=/home/dpflug/.commonrc_local disable=SC1091
. ~/.commonrc_local
fi