blob: b9b875d7ff7c8610b33c73f8e40d5d174902ddde (
plain)
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
|
zstyle ':completion:*' completer _complete _ignored
zstyle :compinstall filename '/home/shmibs/.zshrc'
setopt completealiases
setopt interactivecomments
autoload -U compinit
compinit
autoload -U colors
colors
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt HIST_IGNORE_DUPS
# urxvt does visual mode just fine, and i don't compose
# any large strings in a shell, so treating it as always
# insert mode is more sensible
bindkey -e
setopt notify
unsetopt beep
PROMPT="%{%B$fg[white]%}[%{%(!.$fg[red].$fg[magenta])%}%n@%M %{$fg[blue]%}%c%{$fg[white]%}]: %{%b$reset_color%}"
################# HIGHLIGHTING ################
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
#ZSH_HIGHLIGHT_STYLES[alias]="fg=yellow"
#ZSH_HIGHLIGHT_STYLES[builtin]="fg=yellow"
#ZSH_HIGHLIGHT_STYLES[function]="fg=yellow"
#ZSH_HIGHLIGHT_STYLES[command]="fg=yellow"
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]="fg=red"
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]="fg=red"
# highlight comments
ZSH_HIGHLIGHT_PATTERNS+=('\#*' 'fg=cyan')
################# KEYBINDINGS #################
typeset -g -A key
key[F1]='^[[11~'
key[F2]='^[[12~'
key[F3]='^[[13~'
key[F4]='^[[14~'
key[F5]='^[[15~'
key[F6]='^[[17~'
key[F7]='^[[18~'
key[F8]='^[[19~'
key[F9]='^[[20~'
key[F10]='^[[21~'
key[F11]='^[[23~'
key[F12]='^[[24~'
key[Backspace]='^?'
key[Insert]='^[[2~'
key[Home]='^[[7~'
key[PageUp]='^[[5~'
key[Delete]='^[[3~'
key[End]='^[[8~'
key[PageDown]='^[[6~'
key[Up]='^[[A'
key[Left]='^[[D'
key[Down]='^[[B'
key[Right]='^[[C'
bindkey ${key[Backspace]} backward-delete-char
bindkey ${key[Insert]} overwrite-mode
bindkey ${key[Home]} beginning-of-line
bindkey ${key[Delete]} delete-char
bindkey ${key[End]} end-of-line
bindkey ${key[Up]} up-line-or-search
bindkey ${key[Left]} backward-char
bindkey ${key[Down]} down-line-or-search
bindkey ${key[Right]} forward-char
bindkey ${key[PageUp]} history-beginning-search-backward
bindkey ${key[PageDown]} history-beginning-search-forward
bindkey '^W' backward-kill-word
bindkey '^U' backward-kill-line
bindkey '^P' up-history
bindkey '^N' down-history
################### ALIASES ##################
alias ag='ag --color-match "1;34"'
alias diff='colordiff'
alias grep='grep --color=auto'
alias latex='latex -output-format=pdf'
alias less='less -R'
alias ls='ls --color=auto'
# ignore non-tracked files
git() {
if [[ $# -gt 0 ]] && [[ "$1" == "status" ]]; then
shift
$(which -p git) status -uno "$@"
else
$(which -p git) "$@"
fi
}
alias def='sdcv'
alias dvd='mpv --deinterlace=yes dvd://'
alias ssh-socks='ssh -C2qTnN -D 9853 shmibbles.me'
alias svim='sudo -E vim'
alias thesaurus='aiksaurus'
alias vmount='udevil mount'
alias vumount='udevil umount'
alias :q='exit'
export EDITOR="vim"
export PAGER="less -R"
################## FUNCTIONS ##################
b2h() {
suffixes=( 'B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y' )
sindex=1
val=$1
[[ -z $(echo $1 | grep "^[0-9]*$") ]] && read val
while [[ $(echo $val / 1024 | bc) -ne 0 ]]; do
val=$(echo "scale=2; $val / 1024" | bc)
let sindex=sindex+1
done
echo "${val}${suffixes[$sindex]}"
}
scap() {
archey3
sleep .1
rm /tmp/out.webm
ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 \
-c:v libvpx -b:v 4M -threads 4 /tmp/out.webm > /dev/null 2>&1
}
send() {
if [ "$1" ]; then
scp $@ shmibbles.me:http/tmp/
if [ $? -eq 0 ]; then
for name in "$@"
do
name=$(echo "http://shmibbles.me/tmp/$(basename $name)"\
| sed 's/ /%20/g')
echo $name | tr -d '\n' | xclip -i -selection clipboard
echo $name | tr -d '\n' | xclip -i -selection primary
done
fi
else
echo "specify at least one file to send"
fi
}
sendi() {
if [ "$1" ]; then
scp $@ shmibbles.me:http/img/
if [ $? -eq 0 ]; then
for name in "$@"
do
name=$(echo "http://shmibbles.me/img/$(basename $name)"\
| sed 's/ /%20/g')
echo $name | tr -d '\n' | xclip -i -selection clipboard
echo $name | tr -d '\n' | xclip -i -selection primary
done
fi
else
echo "specify at least one file to send"
fi
}
ssh-firefox() {
xpra start ssh:shmibs@shmibbles.me:1 --pulseaudio --exit-with-children --start-child="firefox"
# this shouldn't be necessary, but just to make sure
xpra stop ssh:shmibs@shmibbles.me:1
}
ssh-scrot() {
archey3
if [[ "$1" != "" ]]; then
name=$1
else
echo -n "name: "
read name
fi
date=$(date +'%Y-%m-%d')
folder="http/img/scrot"
ssh shmibbles.me "mkdir -p $folder/$date"
if [[ "${?#0}" != "" ]]; then
return 1
fi
ssh shmibbles.me "rm $folder/current 2>/dev/null; ln -s $folder/$date $folder/current"
for i in {3..1}; do
echo -n "$i "
sleep 1
done
echo 'cheese!'
sleep .1
scrot /tmp/$name.png
convert -scale 250x /tmp/$name.png /tmp/${name}_small.png
scp /tmp/$name.png /tmp/${name}_small.png shmibbles.me:http/img/scrot/$date
echo "http://shmibbles.me/img/scrot/$date/$name.png" | tr -d '\n' | xclip -i -selection clipboard
echo "http://shmibbles.me/img/scrot/$date/$name.png" | tr -d '\n' | xclip -i -selection primary
echo "http://shmibbles.me/img/scrot/$date/${name}_small.png" | tr -d '\n' | xclip -i -selection clipboard
echo "http://shmibbles.me/img/scrot/$date/${name}_small.png" | tr -d '\n' | xclip -i -selection primary
echo 'sent!'
rm /tmp/$name.png /tmp/${name}_small.png
}
# yay imagemagick
update-backdrops() {
resolution=( ${(s:x:)$(xrandr | grep "*+" | cut -d ' ' -f 4)} )
IFS=$'\n'
for f in $(find ~/backdrops/(*.png|*.jpg)); do
base="$(basename $f)"
geometry=( ${(s: :)$(identify -format "%w %h" $f)} )
if [[ $(calc "(${geometry[0]}/${geometry[1]}) > 1.7778" | \
tr -d '\t') != "0" ]]; then
scale="x${resolution[1]}"
crop="${resolution[0]}x"
else
scale="${resolution[0]}x"
crop="x${resolution[1]}"
fi
if [[ ! -f "$HOME/backdrops/shadowed/$base" ]]; then
echo "$base..."
convert \
-page +0+0 "$f" \
-scale $scale \
-crop $crop \
-page +0+0 "$HOME/backdrops/dropshadow/shadow.png" \
-composite \
"$HOME/backdrops/shadowed/$base"
fi
done
}
make-gif() {
if [[ -z "$1" ]]; then
break
fi
rm -f make-gif-palette.png
rm -f make-gif-palette.png
rm -f make-gif-in
rm -f make-gif-in
ln -s "$1" make-gif-in
echo -n "start [00:00:00]: "
read start
if [[ -z "$start" ]]; then
start="00:00:00"
fi
echo -n "length [full]: "
read length
if [[ -z "$length" ]]; then
t=""
length=""
else
t="-t"
fi
echo -n "fps [10]: "
read fps
if [[ -z "$fps" ]]; then
fps="10"
fi
echo -n "width [480]: "
read width
if [[ -z "$width" ]]; then
width="480"
fi
echo -n "use subtitles? [y/N]: "
read subs
if [[ "$subs" == "y" || "$subs" == "Y" ]]; then
subs="true"
else
subs=""
fi
if [[ $subs ]]; then
ffmpeg -y -ss "$start" $t "$length" -i "$1" \
-copyts -vf "subtitles=make-gif-in,fps=$fps,scale=$width:-1:flags=lanczos,palettegen" make-gif-palette.png
ffmpeg -ss "$start" $t "$length" -i "$1" -i make-gif-palette.png \
-copyts -filter_complex \
"subtitles=make-gif-in,fps=$fps,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" \
out.gif
else
ffmpeg -y -ss "$start" $t "$length" -i "$1" \
-vf "fps=$fps,scale=$width:-1:flags=lanczos,palettegen" make-gif-palette.png
ffmpeg -ss "$start" $t "$length" -i "$1" -i make-gif-palette.png -filter_complex \
"fps=$fps,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" \
out.gif
fi
rm -f make-gif-palette.png
rm -f make-gif-in
}
fuck() {
fuck="fuck"
while true; do
echo -en "\e[$((RANDOM%2));$((RANDOM%8+30))m"
for i in {1..4}; do
if [[ $((RANDOM%2)) -eq 1 ]]; then
echo -n $fuck[$i] | tr '[:lower:]' '[:upper:]'
else
echo -n $fuck[$i]
fi
done
for i in {1..$((RANDOM%20))}; do
echo -n " "
done
done
}
|