Does anybody else have a library of saved commands/scripts? What’s in it? How do you organize it? Is there anything you’d want to share that other people might find helpful?
I do. I keep it in VS Code and store complicated (for me) stuff that I can’t remember or worry I might not.
-
Playlist download with yt-dlp with all my best settings, adding playlist index as track number.
-
Ffmpeg metadata cleaner for music. Searching title for a bunch of specific strings to remove, setting the band, album, etc. and saving these in a new folder.
-
Desktop file contents for when I need to create one for an appimage
-
The script I used to bind audio output switching to a hotkey
-
How to use ADB for when android blocks sideloading the normal way and I inevitably forget what Android Debug Bridge is or how to use it.
Linux Mint btw. Also yes, I am a noob.
Yes, it’s called
export HISTSIZE=10000000
Sorry, late to the party. I like to use variations of them for debugging:
red="$(tput setaf 1)" #green="$(tput setaf 2)" yellow="$(tput setaf 3)" blue="$(tput setaf 4)" reset="$(tput sgr0)" messg() { printf '%-20s\t%s\n' "$1" "$2"; } warn() { messg "${yellow}Warn${reset}:" "$1"; } error() { messg "${red}Error:" "$1" >&2; [ -n "$2" ] && exit "$2"; } # complain to STDERR and exit if given code debug() { [ -n "$debug" ] && messg "${blue}$1${reset}" "$2"; } [ "$debug" = "verbose" ] && set -x if [ -n "$debug" ]; then alias rm='rm -v' alias mv='mv -v' alias mkdir='mkdir -v' alias ln='ln -v' fiAnd those for config/state management:
get_state() { grep "$1" "$state_file" 2>/dev/null |cut -d':' -f2; } set_state() { printf '%s:%s\n' "$1" "$2" >> "$state_file"; } get_conf() { cut -d'#' -f1 "$config_file" |grep -- "$1" |cut -d"=" -f2- ; } set_conf() { #: gracefully sets config options #: meaning: changes value if key exists, creates it if not key="$1" value="$2" config="$config_file" if grep -Eq "${key}=" "$config" then sed -Ei "s/$key=.*/$key=$value/g" "$config" else printf '%s=%s\n' "$key" "$value" >> "$config" fi }And a few more:
isexec() { [ -x "$(command -v "$1" 2>/dev/null)" ]; } contains() { case "$1" in *${2}*) return 0;; *) return 1;; esac; }


