-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcuts.toml
568 lines (481 loc) · 14 KB
/
shortcuts.toml
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
# This file is converted by https://github.com/seanbreckenridge/shortcuts
# into standalone shell scripts
default_shebang = "#!/bin/sh"
# default_mode = "0755"
[list-config]
shebang = "#!/usr/bin/env zsh"
command='''
# list all of my configuration files, by matching combining
# yadm ls-files and a couple search commands
{ cd && yadm ls-files | sed "s#^#$HOME/#"; fd --type=file -H --full-path "${HOME}" "${XDG_CONFIG_HOME}/todo" "${ZDOTDIR}" "${XDG_CONFIG_HOME}/yadm" -E "repo.git"} | grep -v "system-config" | exists | sort -u
'''
[ec]
command = '''
# fuzzy match list-config names, open one to edit (Edit Config)
list-config | sed "s#^$HOME/##g" | fzf +m -q "$*" | xargs -r -I {} editor "$HOME/{}"'''
[restart-emacs]
command = """
# restart the emacs server managed by systemd
if systemctl --user restart emacs; then
notify "restarted emacs server"
else
notify "couldn't restart emacs server"
fi
"""
[refresh-doom]
command = '''
# open a terminal, run doom sync, and restart the emacs daemon
launch "doom sync && restart-emacs"
'''
[dotfiles]
command = '''
# open the dotfiles git repository
cd "${HOME}/.config/yadm/repo.git"
exec gitopen
'''
[dotfiles-github]
command='''
cd "${HOME}/.config/yadm/repo.git"
exec githubopen
'''
[i3binds]
command='''
# print i3 bindings
# ignore volume and brightness bindings
sed 's/^bindsym --release/bindsym/g' "${HOME}/.config/i3/config" | awk '/^bindsym/ {$1=""; print substr($0, 2)}'
'''
[i3binds-prompt]
command='''
# prompt i3 bindings w/ rofi and run one of the commands
i3-msg "$(i3binds | rofi -dmenu -width 50 -lines 30 -location 5 -p "Pick a command to run > " | sed 's/--no-startup-id //g' | cut -d" " -f 2-)"'''
[reload-browser]
command='''
# reload firefox
exec xdotool search --class "Firefox" key --window %@ "ctrl+r"
'''
[usdate]
command = '''
# print the date in the us format
date "+%m/%d/%y"
'''
[gi]
command = '''
# get gitignores for different languages
if [ ! "$(echo "$@" | tr -d "\n\r")" = "" ] && [ ! "$1" = "list" ]; then
printf "tags*\n*.pdf\n"
fi
curl -sL "https://gitignore.io/api/$*"
printf "\n"
'''
[wfi]
command='''
# wait for internet connection and ping me
wait-for-internet "$@" && notify "INTERNET" && playping
'''
[wfib]
command='''
# wfi, and then reload the browser
wfi
exec reload-browser
'''
[moviesearch-trakt]
command = '''
# searches trakt for a movie
[ -z "$SEARCH_STR" ] && SEARCH_STR=$(input-dialog "Search for a movie > " | awk '{$1=$1; print}' | tr " " "+") # awk removes leading/trailing spaces
[ -z "$SEARCH_STR" ] && exit 1
openurl "https://trakt.tv/search/movies?query=${SEARCH_STR}&utf8=%E2%9C%93"
'''
[moviesearch-letterboxd]
command = '''
# searches letterboxd for a movie
[ -z "$SEARCH_STR" ] && SEARCH_STR=$(input-dialog "Search for a movie > " | awk '{$1=$1; print}' | tr " " "+") # awk removes leading/trailing spaces
[ -z "$SEARCH_STR" ] && exit 1
openurl "https://letterboxd.com/search/films/${SEARCH_STR}"
'''
[moviesearch]
command = '''
# searches trakt/letterboxd for a movie
SEARCH_STR=$(input-dialog "Search for a movie > " | awk '{$1=$1; print}' | tr " " "+") # awk removes leading/trailing spaces
[ -z "$SEARCH_STR" ] && exit 1
export SEARCH_STR
moviesearch-trakt &
moviesearch-letterboxd &
wait
'''
[tvsearch]
command = '''
# searches trakt for a tv show
SEARCH_STR=$(input-dialog "Search for a TV show > " | awk '{$1=$1; print}' | tr " " "+")
[ -z "$SEARCH_STR" ] && exit 1
openurl "https://trakt.tv/search/shows?query=${SEARCH_STR}&utf8=%E2%9C%93"
'''
[mediasearch]
command = '''
if SELECTED=$(printf "moviesearch\ntvsearch" | picker -p "Search Media Type > "); then
"$SELECTED"
fi
'''
[genpass]
shebang = "#!/usr/bin/env bash" # to make sure echo flags work
command ='''
# generates a password and puts it on your clipboard
# uses https://github.com/seanbreckenridge/genpasswd
if ! pw=$(genpasswd "$@"); then
echo "$pw"
exit 0
fi
pw=$(head -n 1 <<<"$pw")
if [[ "$(tty)" == "not a tty" ]]; then
notify "Copied password to clipboard:" "${pw}"
else
echo -e "$pw"
fi
# copy to clipboard
echo -en "$pw" | clipcopy
'''
# confirm this is ignoring the correct files by running:
# list-music | grep -Ev "(mp3|flac|ogg|m4a)$"
[list-music]
command='''
# list music files (try to ignore cue/log/album artwork files) in the current directory
fd --type f | grep -iEv "\.(gif|accurip|jpg|png|cue|log|m3u|m3u8|nfo|md5|txt|jpeg|sfv|pdf)$" | sort -n
'''
[play-music]
command='''
# play music in the current directory, recursively
list-music | mpv --playlist=- --no-audio-display
'''
[shuffle-music]
command='''
# Plays songs from this folder, recursively, randomly
list-music | shuf | mpv --playlist=- --no-audio-display
'''
[shfmt-in-place]
command='''
# call shfmt on multiple files
[ -z "$1" ] && echo "Error: must provide a file to call shfmt on." && exit 1
for f in "$@"; do
shfmt "$f" >/tmp/shfmt-temp && cat /tmp/shfmt-temp >"$f"
done
'''
[screenshot-to-imgur]
command='''
# uploads the most recent screenshot from
# ~/Pictures/Screenshots to imgur
FILENAME="$(newest "${SCREENSHOTS:?No SCREENSHOTS environment variable set}")" || exit 1
imgur-uploader "$FILENAME"
IMGUR_URL="$(clippaste)"
printf "%s\n" "$IMGUR_URL" >>/tmp/imgur_urls.log
notify "Uploaded Image to Imgur:" "$IMGUR_URL"
'''
[twitch]
command = '''
# open chatterino and use mpv to stream from twitch
STREAMER="${1:?Pass the twitch user to stream from as the first argument.}"
pgrep -x chatterino >/dev/null || setsid chatterino >/dev/null 2>&1 &
MPVF_PICKER=rofi setsid mpvf "https://www.twitch.tv/${STREAMER}" >/dev/null &
'''
[clipedit]
command = '''
# edit your clipboard in vim
clippaste | vipe | clipcopy
'''
link = 'edit-clipboard'
# shorthand for clipcopy
[cl]
command='clipcopy'
[clipreset]
command='''
# reset the clipboard formatting
clippaste | clipcopy
'''
[lynx]
command = '''
# override the lynx binary by
# placing the lynx shortcut
# on $PATH first
LYNX_PATH="$(findbinary lynx)" || exit $?
"$LYNX_PATH" -accept_all_cookies -cfg="${XDG_CONFIG_HOME}/lynx/lynx.cfg" "$@"
'''
[ranger]
command='''
# override the ranger binary by
# placing the ranger shortcut
# on $PATH first
# this is to ignore Pillow image
# warnings like:
# https://i.imgur.com/Ky6NhKm.png
export PYTHONWARNINGS="ignore"
RANGER_PATH="$(findbinary ranger)" || exit $?
python3 "$RANGER_PATH" "$@"
'''
[printer-server]
command = '''
# open the printer interface in the browser
PRINTER_PORT=$(sudo cat /etc/cups/cupsd.conf | grep -i "Listen localhost" | cut -d":" -f2)
printf "localhost:%d" "$PRINTER_PORT" | openurl
'''
[drive-mount]
command= '''
# start the ldm (light device mounter) daemon, to mount devices
echo "use lsblk -f to view disk IDs"
exec sudo ldm -u "$(whoami)"
'''
[ipinfo]
command='''
# get my ip information
curl -s ipinfo.io | gron | grep -v 'json.readme' | gron -u | jq -r 'to_entries[] | "\(.key): \(.value)"'
'''
[qtile-notify-bindings]
command='''
# send a notification with qtile launcher keybindings
notify-send -t 10000 "qtile bindings:" "$(qtile-bindings --json | jq -r '[.[]|select(.modifier=="control, mod4")] | .[] | "\(.keysym) | \(.command)"' | sed -e "s/spawn('//" -e "s/')$//" -e "s/launch //" -e "s/-developer-edition//" -e "/qtile-notify-bindings/d")"
'''
[webcam-test]
command='''mpv /dev/video0'''
[geolocate]
command='''
IP_ADDR="${1:?provide ip address to geolocate as the first argument}"
curl --silent "https://ipvigilante.com/${IP_ADDR}" | gron | grep -vE 'ipv4|null|status' | gron -u | jq -r '.data | to_entries[] | "\(.key): \(.value)"'
'''
[image-dimensions]
command='''
#!/bin/sh
# print the image dimensions for one or more images
for f in "$@"; do
img_size="$(exiftool "$f" | grep "Image Size")"
[ -z "$img_size" ] && printf "Could not get 'Image Size' for %s" "$f" 1>&2 || printf "%s %s\n" "${img_size#*: }" "$f"
done
'''
[remove-extension]
command='''
# remove the extension from a filename
FILEPATH="${1:?You must provide a filepath to remove the extension for.}"
echo "${FILEPATH%%.*}"
'''
[replace-extension]
command='''
# replace the extension for a filename
FILEPATH="${1:?Have to provide a filepath to replace the extension for}"
REPLACE_EXTENSION="${2:?Must provide extension to replace extension with}"
echo "${FILEPATH%%.*}.${REPLACE_EXTENSION#.}"
'''
[to-png]
command='''
# convert an image to png
FILEPATH=${1:?Must provide image to convert}
convert "$FILEPATH" "$(replace-extension "$FILEPATH" png)"
'''
[to-icon]
command='''
# convert an image to a 16x16 icon - to favicon size
FILEPATH=${1:?Must provide image to convert}
NEW_FILEPATH="$(remove-extension "$FILEPATH")-icon.png"
exec convert -resize x16 -gravity center -crop 16x16+0+0 -flatten -colors 256 "$FILEPATH" "$NEW_FILEPATH"
'''
[file-mime]
command='''
# get mime type for one or more files
# this is the same as what rifle (ranger) does
exec file --mime-type -Lb "$@"
'''
[dragon-sink]
shebang="#!/usr/bin/env bash"
command='''
# brings up a prompt to drag files into.
# If no flags are provided, copies any files
# dragged into the prompt into the current directory.
# if the --mv flag is provided, moves files instead
declare cmd drg files
[[ "$1" = "--mv" ]] && cmd="mv" || cmd="cp"
drg="$(command -v dragon-drag-and-drop)" || drg="$(command -v dragon)" || {
echo "couldnt find the dragon-drag-and-drop or dragon command"
exit 1
}
files="$("$drg" --target --and-exit)"
[[ -z "$files" ]] && exit 1
while IFS= read -r f; do
path="${f#file://}"
$cmd -v "${path}" "$(pwd)/$(basename "${path}")"
done <<<"$files"
'''
# shorthand for sending lines from vim to pastebin
[vix]
command='exec ix -v'
[clp]
command='''
# accepts input from STDIN, sends text back to STDOUT
# copies what it recieved to the clipboard
# used in vim:
# see https://exobrain.sean.fish/vim/magic_wands/
STDIN="$(cat)"
printf '%s' "$STDIN"
printf '%s' "$STDIN" | clipcopy
exec notify "clp" "$(printf 'Copied %d lines to clipboard' "$(echo "$STDIN" | wc -l)")"
'''
# lots of date shorthands
[tstamp]
command="date +'%Y%m%d%H%M%S'"
[now]
command='date +"%A, %B %e, %Y, %l:%M:%S%p"'
[epoch]
command='date +"%s"'
[epochdisplay]
shebang='#!/usr/bin/env python3'
command='''
import sys, time
if len(sys.argv) <= 1:
raise RuntimeError("Must pass epoch time to display as first argument")
print(time.strftime('%y-%m-%d %H:%M:%S', time.localtime(int(sys.argv[1]))))
'''
link='displayepoch'
[weekday]
command='date +"%A" | lower'
[month]
command='date +"%B" | lower'
[year]
command='date +"%Y"'
[lower]
command="tr '[:upper:]' '[:lower:]'"
[upper]
command="tr '[:lower:]' '[:upper:]'"
[capitalize]
shebang="#!/usr/bin/env bash"
command="""
# capitalizes the first character of a word from STDIN
s="$(lower)"
echo "$(upper <<<"${s:0:1}")${s:1}"
"""
[newest]
shebang="#!/usr/bin/env bash"
command='''
# gets the most recently modified file
# from a directory
IFS=$'\n'
f=($(ls -1 --color=never -trd "${1:-.}"/*)) || exit 1
echo "${f[-1]}"
'''
[lastpic]
command='exec newest "${SCREENSHOTS:?No SCREENSHOTS environment variable set}"'
[previewlastpic]
command='lastpic | sxiv - || exit 1'
link="lastpicpreview"
[lastpicdrag]
command='dragon-drag-and-drop -x "$(lastpic)"'
link="draglastpic"
[urlpic]
command='''
# preview a picture from a URL
rm -rf /tmp/urlpic
mkdir -p /tmp/urlpic && cd /tmp/urlpic || exit 1
wget -q "${1:?Must provide a image URL to preview}"
exec mpv --loop "$(newest)"
'''
link="preivewurlpic"
[lastdown]
command='exec newest "${DOWNLOADS:?No DOWNLOADS environment variable set}"'
[mvlast]
command='''
FILE="$(lastdown)" || exit 1
exec mv -v "${FILE}" "./$1"
'''
[mvlastpic]
command='''
FILE="$(lastpic)" || exit 1
exec mv -v "${FILE}" "./$1"
'''
[rbg]
shebang="#!/usr/bin/env bash"
command="echo -n $'\033[38;2;'$1';'$2';'$3'm'"
[rbgb]
shebang="#!/usr/bin/env bash"
command="echo -n $'\033[48;2;'$1';'$2';'$3'm'"
[vic]
command='''
EXECUTABLE="${1:?No Executable provided}"
LOCATION="$(which "$EXECUTABLE")" || exit $?
nvim "$LOCATION"
'''
[grep-dotfiles]
shebang="#!/usr/bin/env bash"
command='''
# searches all my configuration for a string
# passes arguments received to grep
while read -r filename; do
grep -Hrin "$@" "$filename"
done < <(list-config | grep -vE "zsh_history|compdump")
'''
[cheat]
shebang="#!/bin/sh"
command='curl "https://cheat.sh/$*"'
# runs git pull in all my repos in parallel (in 3 seconds). reports errors
[repos-pull-all]
shebang="#!/usr/bin/env zsh"
command='''
fd -H --absolute-path --type d --regex "${REPOS}/[^/]+/\.git$" --full-path "$REPOS" | parallel -j 500% "cd {}/.. && has-git-remote && { git pull --quiet && printf '.' || { echo; pwd} }"
echo
'''
[speedtest]
command='wait-for-internet --text "Waiting for internet..." && exec python3 -m speedtest'
[rcut]
command='''
# cut, but indexing from the right
rev | cut "$@" | rev
'''
[mpv-corner]
command='''
# mpv wrapper to open a video with mpv and put it in the bottom right corner
setsid -f mpv --x11-name=mpv_stream_media "$@" >/dev/null 2>&1
'''
[youtube-dl]
command='''python3 -m youtube_dl -o '%(title)s.%(ext)s' -ci "$@"'''
[create-youtube-dl-resolution-str]
command='''
# defaults to about 480p
# otherwise, grabs the format from the FORMAT environment variable
# prints the format string for a particular resolution
FORMAT="${FORMAT:-550}"
exec printf 'bestvideo[height<=%d]+bestaudio/best[height<=%d]' "$FORMAT" "$FORMAT"
'''
[stream-corner]
command='''
# streams and sets the instance name on the mpv window
# this is used with a for_window hook in i3 to put the
# window in the bottom right
stream-media --x11-name=mpv_stream_media "$@"
'''
[stream-corner-at]
command='''
# pass the resultion to stream as the first argument
# defaults to about 480p
STREAM_MEDIA_CMD=mpv stream-corner --ytdl-format="$(create-youtube-dl-resolution-str)" "$@"
'''
[stream-corner-480]
command='stream-corner-at "$@"'
[stream-corner-720]
command='''
export FORMAT=850
stream-corner-at "$@"
'''
[stream-audio]
command='STREAM_MEDIA_CMD=mpv stream-media --no-video "$@"'
[youtube-dl-at]
command='''
# set the FORMAT environment variable to control resolution
youtube-dl -f "$(create-youtube-dl-resolution-str)" "$@"
'''
[youtube-dl-480]
command='''
# download at about 480p
youtube-dl-at "$@"
'''
[youtube-dl-720]
command='''
# download at about 720p
export FORMAT=850
youtube-dl-at "$@"
'''
[discord]
command="openurl 'https://discord.com/login'"
[slack]
command="openurl 'https://app.slack.com/'"