-
Notifications
You must be signed in to change notification settings - Fork 0
/
shortcuts.toml
965 lines (807 loc) · 21.9 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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
# This file is converted by https://github.com/purarue/shortcuts
# into standalone shell scripts
default_shebang = "#!/bin/sh"
[list-config]
shebang = "#!/bin/zsh"
command = '''
# list all of my configuration files, by matching combining
# yadm list and a couple search commands
cd # home
{
yadm list | sed "s#^#$HOME/#"
echo "$HOME/.config/yadm/README.md"
echo "$HPIDATA/personal_aliases"
fd --type=file -H -E '__pycache__' -E '.mypy_cache' --full-path "${HOME}" "${XDG_CONFIG_HOME}/todo" "${ZDOTDIR}"
} | grep -v "system-config" | exists | sort -u
'''
[ec]
command = '''
cd ~ || exit $?
# fuzzy match list-config names, open one to edit (Edit Config)
fzfcache list-config-no-hist | sed "s#^$HOME/##g" | fzf-edit
'''
[dotfiles]
command = '''
# open the dotfiles git repository
yadm open --print | openurl
'''
[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 firefox (Navigator is firefox's WM_CLASS)
# the i is to enter insert mode in firefox (I use vimium)
# \C is control, r is r, to refresh
[reload-browser]
command = '''
exec xvkbd -window Navigator -text "i\Cr"
'''
[usdate]
command = '''
# print the date in the us format
exec date "+%m/%d/%y"
'''
[tstamp]
command = "exec date +'%Y%m%d%H%M%S'"
[gi]
command = '''
# get gitignores for different languages
if [ ! "$(echo "$@" | tr -d "\n\r")" = "" ] && [ ! "$1" = "list" ]; then
printf "*.pdf\n"
fi
curl -sL "https://gitignore.io/api/$*"
printf "\n"
'''
[wfi]
command = '''
# wait for internet connection and ping me
command -v tttlog >/dev/null 2>&1 && tttlog "$(basename "$0")"
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 > " | chomp | tr " " "+")
[ -z "$SEARCH_STR" ] && exit 1
command -v tttlog >/dev/null 2>&1 && tttlog "$(basename "$0") $SEARCH_STR"
exec 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 > " | chomp | tr " " "+")
[ -z "$SEARCH_STR" ] && exit 1
command -v tttlog >/dev/null 2>&1 && tttlog "$(basename "$0") $SEARCH_STR"
exec openurl "https://letterboxd.com/search/films/${SEARCH_STR}"
'''
[moviesearch]
command = '''
# searches trakt/letterboxd for a movie
SEARCH_STR=$(input-dialog "Search for a movie > " | chomp | tr " " "+")
[ -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 > " | chomp | tr " " "+")
[ -z "$SEARCH_STR" ] && exit 1
command -v tttlog >/dev/null 2>&1 && tttlog "$(basename "$0") $SEARCH_STR"
exec 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
exec "$SELECTED"
fi
'''
[discogs-search]
command = '''
# https://www.discogs.com/search?q=sampha&type=all
# searches discogs for an album
SEARCH_STR=$(input-dialog "Search for an album > " | chomp | tr " " "+")
[ -z "$SEARCH_STR" ] && exit 1
command -v tttlog >/dev/null 2>&1 && tttlog "$(basename "$0") $SEARCH_STR"
exec openurl "https://www.discogs.com/search/?q=${SEARCH_STR}&type=all"
'''
[genpass-phrase]
command = 'USE_DICEWARE=1 exec genpass "$@"'
[list-images]
command = '''exec fd '.*\.(png|jpeg|jpg|heic)$' "$@"'''
[play-music]
command = '''
# play music in the current directory, recursively
list-music | sort -n | mpv --playlist=- --no-audio-display
'''
[shuffle-music]
command = '''
# Plays songs from this folder, recursively, randomly
list-music | shuf | mpv --playlist=- --no-audio-display
'''
[twitch-stream]
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
launch "clippaste | vipe | clipcopy"
'''
link = 'edit-clipboard'
# shorthand for clipcopy
[cl]
command = 'clipcopy'
[clipreset]
command = '''
# reset the clipboard formatting
notify "resetting clipboard..."
clippaste | clipcopy
'''
[lynx]
shebang = "#!/bin/zsh"
command = '''
# override the lynx binary by
# placing the lynx shortcut
# on $PATH first
LYNX_PATH="$(where lynx | grep -m1 -v "$SHORTCUTS_DIR")" || exit $?
exec "$LYNX_PATH" -accept_all_cookies -cfg="${XDG_CONFIG_HOME}/lynx/lynx.cfg" "$@"
'''
[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)"'
'''
[webcam-test]
command = 'exec /usr/bin/mpv /dev/video0'
[webcam-pic]
command = '''
# open mpv to save a picture (using webcam) in ~/Pictures/pics
declare pics
pics="${XDG_PICTURES_DIR:?XDG_PICTURES_DIR environment variable not set}/pics"
[[ ! -d "$pics" ]] && mkdir -p "$pics"
cd "$pics" || exit 1
# open mpv so I can take a picture
mpv /dev/video0
exec launch ranger "$pics"
'''
shebang = '#!/usr/bin/env bash'
link = 'camera'
[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 magick -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 "$@"
'''
# shorthand for sending lines from vim to pastebin
[vix]
command = 'exec ix -v'
[clp-args]
command = '''
# clp, but accepts input as arguments
echo "$*" | clp
'''
[lastpic]
shebang = "#!/usr/bin/env bash"
command = '''
case "$ON_OS" in
linux*)
exec newest "$@" "${SCREENSHOTS:?No SCREENSHOTS environment variable set}"
;;
mac*)
find "${HOME}/Desktop" -iname 'screen shot*' | tail -n1 || exit $?
;;
esac
'''
[lastpicpreview]
command = 'exec rifle "$(lastpic)"'
[lastpicdrag]
command = 'dragon-drop -x "$(lastpic)"'
link = "draglastpic"
[urlpicpreview]
command = '''
# preview a picture from a URL
img-download "$@" || exit $?
rifle "$(clippaste)"
'''
[mvlastpic]
command = '''
FILE="$(lastpic)" || exit 1
exec mv -v "${FILE}" "./$1"
'''
[vic]
command = '''
EXECUTABLE="${1:?No Executable provided}"
LOCATION="$(command -v "${EXECUTABLE}")" || exit $?
cd "$(dirname "${LOCATION}")" || exit $?
exec editor "$(basename "${LOCATION}")"
'''
[list-config-no-hist]
command = '''
list-config | grep -vE -e "zsh_history|compdump" -e "$SHORTCUTS_DIR"
'''
[grep-dotfiles]
shebang = "#!/usr/bin/env bash"
command = '''
# searches all my configuration for a string
# passes arguments received to grep
list-config-no-hist | xargs grep -Hrin "$@"
'''
[cheat]
command = '''
command -v tttlog >/dev/null 2>&1 && tttlog "$(basename "$0") $*"
exec curl -s "https://cheat.sh/$*"
'''
[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 = '''exec python3 -m yt_dlp -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
exec stream-media --x11-name=mpv_stream_media "$@"
'''
[stream-corner-at]
command = '''
# set the FORMAT environment variable to specify maximum height/width
# defaults to about 480p
STREAM_MEDIA_CMD=mpv exec stream-corner --ytdl-format="$(create-youtube-dl-resolution-str)" "$@"
'''
[stream-corner-480]
command = 'exec stream-corner-at "$@"'
[stream-corner-720]
command = '''
export FORMAT=850
exec stream-corner-at "$@"
'''
[stream-corner-1080]
command = '''
export FORMAT=1100
exec stream-corner-at "$@"
'''
[stream-audio]
command = 'STREAM_MEDIA_CMD=mpv exec stream-media --no-video "$@"'
[youtube-dl-at]
command = '''
# set the FORMAT environment variable to control resolution
exec youtube-dl -f "$(create-youtube-dl-resolution-str)" "$@"
'''
[youtube-dl-480]
command = '''
# download at about 480p
exec youtube-dl-at "$@"
'''
[youtube-dl-720]
command = '''
# download at about 720p
export FORMAT=850
exec youtube-dl-at "$@"
'''
[stream-from-firefox]
command = '''
# copies the current URL from firefox, and starts streaming it with stream-at-480
# escape, then yy (yank the URL; using the vimium extension)
xvkbd -window Navigator -text "\Eyy"
sleep 1 # just to make sure its copied
exec stream-corner-480
'''
[discord-browser]
command = "exec openurl 'https://discord.com/login'"
[feed-open]
command = "exec openurl 'https://purarue.xyz/feed/'"
[newsboat-force]
command = '''
# if another instance of newsboat is open, kill it and open one here
# specifically useful in case newsboat -x reload is going on in the background
pgrep -x newsboat && pkill -x newsboat
cd "${XDG_DOWNLOAD_DIR:-${HOME}/Downloads}" || exit 1
newsboat
exec i3-msg exec update-rss # update rss afterwards, to update menu bar icon
'''
[neomuttr]
command = '''
# neomutt and refresh my menu bar block
neomutt && refresh-block mail
'''
[alacritty-tmux]
command = 'exec alacritty -e tmux'
[extracturls]
command = '''
# receives text from STDIN, extracts unique URLs
# pypi.org/project/urlextract
urls="$(urlextract | sort -u)"
if [ -z "${urls}" ]; then
notify "No URLs found in text"
exit 1
fi
printf "%s\n" "${urls}"
'''
[ssh-keygen-good]
command = 'exec ssh-keygen -t ed25519'
[mystarsfzf]
command = '''
update-my-stars
# https://github.com/purarue/oh-my-stars
PICKED="$(fzfcache mystars "$@" | fzf --ansi -0)" || exit $?
printf '%s\n' "${PICKED}"
URL="$(echo "${PICKED}" | urlextract)"
# if a URL was extracted, copy it to my clipboard
[[ -n "${URL}" ]] && {
printf '%s' "${URL}" | clipcopy
printf '%s\n' "${URL}"
}
'''
shebang = "#!/usr/bin/env bash"
[screenshots]
command = '''
exec nsxiv -t "${SCREENSHOTS}"
'''
[up-live]
command = 'TERM=xterm exec up --unsafe-full-throttle'
shebang = "#!/bin/zsh"
[watchtwitch]
command = '''
twitchlive -output-format json | jq -r '.[] | .username' | picker -p "who to watch? " | xargs -r twitch
'''
[reshortcuts]
command = '''
set -o pipefail
cd || exit $?
[[ -n "${SHORTCUTS_DIR}" ]] && [[ -d "${SHORTCUTS_DIR}" ]] && rm -rf "${SHORTCUTS_DIR}"
echo "Creating/formatting shortcuts..."
DEBUG_OUTPUT="$(shortcuts create --debug && fd . "${SHORTCUTS_DIR}" -X rifleman 2>&1)" || {
echo "$DEBUG_OUTPUT"
}
'''
shebang = "#!/usr/bin/env bash"
[i3-jinja]
command = '''
set -x
I3_DIR="${HOME}/.config/i3"
cd "${I3_DIR}" || exit $?
exec jinjanate config.j2 -o config -f yaml <config.yaml
'''
shebang = "#!/usr/bin/env bash"
[alarm]
command = 'exec paplay /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga'
[synonym]
command = '''
word="${1:?Provide the word to list synonyms as first argument}"
moby "${word}" | grep , | tr , '\n' | chomp
'''
[fzfp]
command = 'exec fzf --preview="${HOME}/.config/fzf_preview {}" "$@"'
[largechar-clipboard]
command = '''
CONTENTS="$(clippaste)"
[ -z "${CONTENTS}" ] && exit 1
printf '%s' "${CONTENTS}" | largechar -c
'''
[syncgui]
command = "exec openurl 'localhost:8384'"
[sqlitebrowser-]
command = '''
# on linux, call the binary directly
havecmd 'sqlitebrowser' && exec sqlitebrowser "$@"
# on mac, this is installed into /Applications/
exec open -a DB\ Browser\ for\ SQLite "$@"
'''
[clr]
command = '''
# I need to spell this out with 'attached-to-terminal' even though print-or-notify does that exact thing because:
# - if I pipe, then the pipe causes print-or-notify to always send a notification because stdin is not a tty or something
# - if I send it like the notify below, if the data returned by ttally recent food is too long in the terminal, it will
# fail since the argument list is too long
args=("$@")
if [[ -z "$1" ]]; then
args+=("--human-readable")
fi
if attached-to-terminal; then
ttally recent food "${args[@]}"
else
notify "$(ttally recent food "${args[@]}")"
fi
'''
shebang = "#!/usr/bin/env bash"
[clrs]
command = '''exec clr -hr quantity,water "$@"'''
[mz]
command = '''
# use cached https://github.com/purarue/projects repository information
# to quickly open one of my Github repositories
chosen="$(jq -r '.[] | .html_url' <"${REPOS}/projects/cache.json" | fzf -0)" || exit $?
echo "$chosen" | clipcopy
'''
[sync-neomutt]
command = '''
# wait for internet, sync my mail, then launch neomutt
wait-for-internet && ms
i3blocks-refresh-mk mail
neomutt || return $?
i3blocks-refresh-mk mail
'''
[trakt-progress]
command = 'exec openurl "https://trakt.tv/users/purplepinapples/progress"'
[mal-recent]
command = 'exec openurl "myanimelist.net/animelist/purplepinapples?status=7&order=5"'
[lynx-from-stdin]
command = 'exec lynx -stdin'
[lynx-dump]
command = 'exec lynx -stdin -dump'
[urldrag]
command = '''
# dragon a picture from my clipboard https://github.com/mwh/dragon
img-download || exit $?
exec dragon-drop -x "$(clippaste)"
'''
[albums]
command = 'exec openurl "https://purarue.xyz/s/albums"'
[boxes-python]
command = '''
# create a comment box as a python comment, text piped from STDIN
exec boxes -dshell -pv1h2 "$@"
'''
[boxes-vim]
command = """boxes-python | tr '#' '\"'"""
[boxes-nvim]
command = "exec boxes -dada-box -pv1h2"
[flake8c]
command = '''
# flake8 with my default config -- https://purarue.xyz/d/.config/flake8?dark
exec flake8 --config ~/.config/flake8 "$@"
'''
[styluac]
command = '''
exec stylua --config-path "$HOME/.config/nvim/stylua.toml" "$@"
'''
[yadm-format]
command = '''
# autoformat all my dotfiles
set -o pipefail
cd
yadm list | exists | grep -v 'lazy-lock.json' | rifleman -
'''
shebang = "#!/usr/bin/env zsh"
[yadm-lint]
command = '''
# run linters on all my dotfiles
set -o pipefail
cd
yadm list | exists | rifleman - -a lint
'''
shebang = "#!/usr/bin/env zsh"
[listens-desc]
command = '''
# https://github.com/purarue/HPI-personal/blob/master/scripts/listens
exec listens --desc "$@"
'''
[yh]
command = '''
cd ~/.local/share/yadm/repo.git/ || exit $?
exec gh "$@"
'''
[calcursed]
command = '''
exec calcurse --datadir "$CALCURSE_DIR" --confdir "$XDG_CONFIG_HOME/calcurse" "$@"
'''
shebang = "#!/usr/bin/env bash"
[cl-quickfix]
command = '''
# pastes text from the clipboard and creates a quickfist list
# this is typically called from kitty -- which saves the
# output of the previous command, then calls this in a new window
# https://github.com/purarue/dotfiles/blob/cdae322fa6b735d5ca12dd3248354b5eeaaab0be/.config/kitty/kitty.conf#L1581-L1588
set -e
exec nvim -q <(clippaste) +copen
'''
shebang = "#!/usr/bin/env bash"
[qf] # quickfix
command = '''
# usually used like qf <(grep -Hrin ...) or qf <(!!)
# to repeat last command and create a quickfix list
exec nvim -q "$@" +copen
'''
[lessi]
command = 'exec less -i "$@"'
[reminder-sink-notify]
command = '''
SR="$(reminder-sink run)"
exec notify "${SR:-No reminders}"
'''
[primes]
command = 'exec primesieve "$@" -p'
[text2html]
command = 'exec pygmentize -f html "$@"'
[tmpfile]
command = '''
ext="${1:-tmp}"
filename="${2:-$(genpasswd -rsym -rnum)}"
echo "$(mktemp -d)/${filename}.${ext}"
'''
[pipehtml]
command = '''
# given HTML on STDIN, create a tempfile with its contents
tmpf="$(tmpfile html "$1")"
cat >"$tmpf"
exec printf '%s\n' "$tmpf"
'''
[html-head-all]
command = 'exec html-head -a css-dark-mode -a css-pre-wrap "$@"'
[pygmentize-styles]
command = """
# shellcheck disable=SC2063
pygmentize -L styles | grep '* ' | cut -c3- | sed -e 's/:$//'
"""
[pygmentize-html-style]
command = '''
style="$(pygmentize-styles | fzf)" || exit $?
exec pygmentize -P style="$style" -O noclasses=True -f html "$@"
'''
[repos]
command = 'exec repos-list -f "$@"'
[realbasename]
command = 'exec basename "$(realpath "$(pwd)")"'
link = "curdir"
[google-chrome-wifi-captive]
command = "exec google-chrome-stable 'http://clients3.google.com/generate_204'"
[update-forks]
command = 'exec clone-repos ~/.config/clone-repos/update-forks.yaml'
[rj] # 'run-jobs'
command = '''
if [[ "$1" == "-o" ]]; then
: # skip internet check, just run the loop once
elif wait-for-internet --quiet --timeout 0; then
exec bgproc_on_machine -pn
fi
export WFI_TIMEOUT=0
exec bgproc_on_machine -on
'''
shebang = "#!/usr/bin/env bash"
[beet-fix-renamed-files]
command = 'exec beet update -F=path "$@"'
[beet-export-all]
command = 'exec beet export "" "$@"'
[sort-by-line-length]
shebang = "#!/usr/bin/env bash"
command = """
set -o pipefail
awk '{ print length, $0 }' | sort -n | cut -d' ' -f2-
"""
[shortest-video]
command = '''
file="$(list-movies -X mlength -o min -d path "$@")"
if [ -n "$file" ]; then
echo "$file"
else
echo "No media found" >&2
exit 1
fi
'''
[play-shortest-video]
command = '''
set -e
if file="$(shortest-video)"; then
exec rifle "$file"
fi
exit 1
'''
[list-videos]
command = 'exec list-movies "$@"'
[mtotal]
command = 'exec mlength -o sum -d m "$@"'
[google-search]
command = '''
TEXT="$(cat)"
if [[ -z "$TEXT" ]]; then
TEXT="$(clippaste)"
fi
exec openurl "https://www.google.com/search?q=${TEXT// /+}"
'''
shebang = "#!/usr/bin/env bash"
[fzf-edit]
command = '''
FILE="$(fzfp +m -q "$*")"
if [[ -n "$FILE" ]]; then
editor "$FILE"
else
echo "No file selected" >&2
exit 1
fi
'''
shebang = "#!/usr/bin/env bash"
[playping-loop]
command = '''
# I use this as a pleasant sounding alarm often, e.g.
# timer 15m && playping-loop
watch playping
'''
[cycle]
command = '''
# moves the first argument to the end of the list
exec awk "$@" '{ for (i = 2; i <= NF; i++) printf $i "\t" ; print $1 }'
'''
[longest-video]
command = 'exec shortest-video -o max "$@"'
[img-download-drag]
command = '''
img-download "$@" || exit $?
dragon-drop -x "$(clippaste)"
'''
[mpv-logfile]
command = '''
MPV_LOGFILE_TMPDIR="${TMPDIR:-/tmp}/mpv-logs"
mkdir -p "$MPV_LOGFILE_TMPDIR"
exec mpv --log-file="$MPV_LOGFILE_TMPDIR/$(date +%s%N).log" "$@"
'''
[tz]
command = 'exec time-in tz "$@"'
[unlines]
command = 'exec paste -sd " "'
[codespell-conf]
command = '''
declare -a args=()
if [[ -n "$NVIM_SPELLFILE" ]]; then
args+=("--ignore-words=$NVIM_SPELLFILE")
fi
exec codespell --config ~/.config/codespell/codespell.conf "${args[@]}" "$@"
'''
shebang = "#!/usr/bin/env bash"
[fdf]
command = 'exec fd --type=file "$@"'
[mypy-single-lines]
command = 'exec mypy --show-column-numbers --hide-error-codes --hide-error-context --no-color-output --no-error-summary --no-pretty "$@"'
[spell-list]
command = 'exec fd --type f "$@" --exec-batch codespell-conf'
[spell-interactive]
command = 'exec fd --type f "$@" --exec-batch codespell-conf --write-changes --interactive 3'
[spell]
command = '''
set -e
spell-list "$@" || true
spell-interactive "$@"
'''
shebang = "#!/usr/bin/env bash"
[rgqf]
command = 'exec rg --no-heading --with-filename --line-number "$@"'
[current-city]
command = "ipinfo | grep -m1 city | cut -d':' -f2- | chomp"
[core]
command = '''
export BASE_URL='https://purarue.xyz/c/'
exec give
'''
[which-cat]
command = '''
# I have a which-cat zsh function as well, this is a fallback for scripts
# or when I'm in nvim
EXEC="${1:?Must provide executable as first argument}"
if LOC="$(which "$EXEC")" >/dev/null 2>&1; then
cat "$LOC"
else
printf "Could not find %s\n" "$EXEC" >&2
fi
'''
[url-echo-redirect]
command = '''
# echo the URL that would be redirected to
URL="${1:-"$(cat)"}"
if [[ -z "$URL" ]]; then
echo "No URL provided" >&2
exit 1
fi
exec curl -w "%{url_effective}\n" -ILsS "$URL" -o /dev/null
'''
shebang = "#!/usr/bin/env bash"
# shortcut for flatpak pinta
[pinta]
command = 'exec flatpak run com.github.PintaProject.Pinta'
[unicode]
command = '''
file="${TMPDIR:-/tmp}/unicode_input"
kitty -- sh -c "kitten unicode_input >\"$file\"" || exit $?
contents="$(cat "$file")"
[[ -z "$contents" ]] && exit 1
clp <<<"$contents"
rm -f "$file"
'''
shebang = "#!/usr/bin/env bash"
[mpv-drag-screenshot]
command = '''
path="$(mpv-last-screenshot)"
[ -n "$path" ] && exec dragon-drop -x "$path"
'''
[screenshot-upload]
command = 'exec remsync-image "$(lastpic)"'
[mpv-last-screenshot-upload]
command = 'exec remsync-image "$(mpv-last-screenshot)"'
[markdown-list]
command = "exec prefix '- '"
[qr-clipboard]
command = 'clippaste | qr'
[exo-web]
command = 'exec openurl "https://purarue.xyz/x/notes/?search"'
[render-notes]
command = 'exec make -f "$HOME/.local/scripts/notes_rendered/Makefile" "$@"'
[todo]
command = 'exec todo.sh "$@"'
[kitty-set-theme]
command = '''
kitty +kitten themes --reload-in=all "${1:?Must provide theme as kwarg}" || exit $?
echo "$1" >~/.cache/kitty-theme-name
'''
shebang = "#!/usr/bin/env bash"
[light-theme-kitty]
command = '''
exec kitty-set-theme Light
'''
[dark-theme-kitty]
command = '''
exec kitty-set-theme Dark
'''
[abookc]
command = 'exec abook -C "$XDG_CONFIG_HOME/abook/abookrc" -f "$XDG_DOCUMENTS_DIR/addressbook" "$@"'
[epoch-from]
command = '''
exec dates-stdin -Fepoch <<<"$@"
'''
shebang = '#!/usr/bin/env bash'
[heart-cl]
command = '''
heart | APP=heart clp
'''
[timer-till-playping]
command = '''
timer-till "$*" && playping-loop
'''