# 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) chosen="$(fzfcache list-config-no-hist | sed "s#^$HOME/##g" | fzfp +m -q "$*")" || exit $? [ -n "$chosen" ] && exec vim "$chosen" ''' [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 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 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 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 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 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="$(where "${EXECUTABLE}" | grep -v "pipx_isolate/bin" | head -n1)" || exit $? cd "$(dirname "${LOCATION}")" || exit $? exec vim "$(basename "${LOCATION}")" ''' shebang = "#!/bin/zsh" [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 = ''' 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/'" [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 ''' [i3-jinja] command = ''' set -x I3_DIR="${HOME}/.config/i3" cd "${I3_DIR}" || exit $? exec jinjanate config.j2 -o config -f yaml "$tmpf" exec printf '%s\n' "$tmpf" ''' [clipboard-image] command = ''' # take image from clipboard, put it in a tmpfile, print path tmpf="$(tmpfile png "$1")" clippaste >"$tmpf" || exit $? exec printf '%s\n' "$tmpf" ''' link = "img-clipboard" [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 exec vim "$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-fd] command = 'exec fd --type f --exclude package-lock.json --exclude yarn.lock "$@"' [spell-list] command = 'exec spell-fd "$@" --exec-batch codespell-conf' [spell-interactive] command = 'exec spell-fd "$@" --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 vim 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" [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 "$@"' [abookc] command = 'exec abook -C "$XDG_CONFIG_HOME/abook/abookrc" -f "${SHARED_DIR}/addressbook" "$@"' [heart-cl] command = ''' heart "$@" | APP=heart clp ''' [timer-till-playping] command = ''' timer-till "$*" && playping-loop ''' # often used like 'git-color diff | ansi2html' # to generate a html file with diff colors [git-color] command = 'exec git -c color.ui=always "$@"' [exif-clear-tags] command = 'exec exiftool -all:all= -r "$@"' [img-auto-orient] command = 'exec mogrify -auto-orient "$@"' [largechar-wifi-password] command = ''' pw="$(nmcli device wifi show-password | grep '^Password' | sed 's/Password: //')" if [ -z "$pw" ]; then echo "No wifi password found" >&2 exit 1 else exec largechar "$(nmcli device wifi show-password | grep '^Password' | sed 's/Password: //')" -c fi '''