+pdfwc() { local f; for f; do echo "$f" "$(pdfinfo "$f" | awk '/^Pages:/ {print $2}')"; done }
+
+
+# nvm install script appended this to my .bashrc. I dont want to run it all the time,
+# so put it in a function.
+nvm-init() {
+ export NVM_DIR="$HOME/.nvm"
+ # shellcheck disable=SC1091 # may not exist, & third party
+ [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm
+ # shellcheck disable=SC1091 # may not exist, & third party
+ [ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" # This loads nvm bash_completion
+}
+
+
+leap-year() {
+ if date -d 'february 29' &>/dev/null; then
+ year_days=366
+ else
+ year_days=365
+ fi
+ echo $year_days
+}
+
+# on-battery
+on-bat() {
+ if [[ -e /sys/class/power_supply/AC/online && $(</sys/class/power_supply/AC/online) == 0 ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+# make vim work with my light colortheme terminal.
+vim() {
+ if [[ -e ~/.vimrc ]]; then
+ command vim "$@"
+ else
+ command vim -c ':colorscheme peachpuff' "$@"
+ fi
+}
+
+# ls count. usage: pass a directory, get the number of files.
+# https://unix.stackexchange.com/questions/90106/whats-the-most-resource-efficient-way-to-count-how-many-files-are-in-a-director
+lsc() {
+ # shellcheck disable=SC2790 disable=SC2012 # intentional
+ ls -Uq "$@"|wc -l
+}
+
+# run then notify. close notification after the next prompt.
+rn() {
+ "$@"
+ dunstify -u critical -h string:x-dunst-stack-tag:profanity "$*"
+ _psrun=(dunstctl close-all)
+}
+n() {
+ dunstify -u critical -h string:x-dunst-stack-tag:profanity n
+ _psrun=(dunstctl close-all)
+}
+
+catnew() {
+ local dir file
+ dir="$1"
+ inotifywait -m "$dir" -e create -e moved_to | while read -r _ _ file; do
+ hr
+ cat "$dir/$file"
+ done
+}
+# cat mail
+cm() {
+ catnew /m/md/$1/new
+}
+
+
+fsf-sv-header() {
+ local f
+ local -a f_maybe
+ if ! type -p sponge &>/dev/null; then
+ echo "$0: error: missing dependency: sudo apt install moreutils" >&2
+ return 1
+ fi
+
+ for f; do
+ echo "adding header to $f"
+ if [[ -s $f ]]; then
+ f_maybe=("$f")
+ else
+ f_maybe=()
+ fi
+ cat - "${f_maybe[@]}" <<EOF | sponge "$f"
+The following is the GNU All-permissive License as recommended in
+<https://www.gnu.org/licenses/license-recommendations.en.html>
+
+Copyright (C) $(date +%Y) Free Software Foundation <sysadmin@fsf.org>
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without any warranty.
+
+Contributions are welcome. See <https://savannah.gnu.org/maintenance/fsf/>.
+
+EOF
+ done
+}
+
+# note, there is also the tool gron which is meant for this, but
+# this is good enough to not bother installing another tool
+jq-lines() {
+ # https://stackoverflow.com/questions/59700329/how-to-print-path-and-key-values-of-json-file-using-jq
+ jq --stream -r 'select(.[1]|scalars!=null) | "\(.[0]|join(".")): \(.[1]|tojson)"' "$@"
+}
+
+tsr() { # ts run
+ "$@" |& ts || return $?
+}
+