ssh-copy-id $1
}
+# ya, hacky hardcoded hostnames in 2023. we could do better
+hssh-update() {
+ for host in kd x3.office.fsf.org syw; do
+ e $host
+ scp /b/fai/fai/config/files/usr/local/bin/hssh/IANK root@$host:/usr/local/bin/hssh
+ done
+}
+
a() {
local x
x=$(readlink -nf "${1:-$PWD}")
}
vp9() {
- local f out outdir in
+ local f out outdir in fname origdir skip1
+ origdir="$PWD"
outdir=vp9
- case $1 in
- --out)
- outdir=$2
- shift 2
- ;;
- esac
+ skip1=false
+ while [[ $1 == -* ]]; do
+ case $1 in
+ # if we got interrupted after 1st phase
+ -2)
+ skip1=true
+ shift
+ ;;
+ --out)
+ outdir=$2
+ shift 2
+ ;;
+ esac
+ done
m mkdir -p $outdir
+ # first pass only uses about 1 cpu, so run in parallel
for f; do
- out=$PWD/$outdir/$f
- in=$PWD/$f
- m cd $(mktemp -d)
- pwd
- m ffmpeg -threads 0 -i $in -g 192 -vcodec libvpx-vp9 -vf scale=-1:720 -max_muxing_queue_size 9999 -b:v 750K -pass 1 -an -f null /dev/null
- m ffmpeg -y -threads 0 -i $in -g 192 -vcodec libvpx-vp9 -vf scale=-1:720 -max_muxing_queue_size 9999 -b:v 750K -pass 2 -c:a libvorbis -qscale:a 5 $out
- cd -
+ {
+ fname="${f##*/f}"
+ if [[ $f == /* ]]; then
+ in="$f"
+ else
+ in=$origdir/$f
+ fi
+ out="$origdir/$outdir/$fname"
+ mkdir -p /tmp/vp9/$fname
+ cd /tmp/vp9/$fname
+ if ! $skip1 && [[ ! -s ffmpeg2pass-0.log ]]; then
+ # -nostdin or else wait causes ffmpeg to go into stopped state. dunno why, random stackoverflow answer.
+ m ffmpeg -nostdin -hide_banner -loglevel error -i $in -g 192 -vcodec libvpx-vp9 -vf scale=-1:720 -max_muxing_queue_size 9999 -b:v 750K -pass 1 -an -f null /dev/null
+ fi
+ if [[ -e $out ]]; then rm -f $out; fi
+ m ffmpeg -nostdin -hide_banner -loglevel error -y -i $in -g 192 -vcodec libvpx-vp9 -tile-rows 2 -vf scale=-1:720 -max_muxing_queue_size 9999 -b:v 750K -pass 2 -c:a libvorbis -qscale:a 5 $out
+ } &
done
+ wait -f
+ cd "$origdir"
}
utcl() { # utc 24 hour time to local hour 24 hour time
# absolute path of file/dir without resolving symlinks.
#
+# Most of the time, I want this where I would normally use readlink.
# This is what realpath -s does in most cases, but sometimes it
# actually resolves symlinks, at least when they are in /.
#
rg() { grr "$@"; }
ccomp grep rg
+# recursive everything. search for files/dirs and lines. rs = easy chars to press
+re() {
+ local query
+ query="$1"
+ find "$@" -not \( -name .svn -prune -o -name .git -prune \
+ -o -name .hg -prune -o -name .editor-backups -prune \
+ -o -name .undo-tree-history -prune \) 2>/dev/null | grep -iP --color=auto "$query"
+ grr -m 5 "$@"
+}
+
hr() { # horizontal row. used to break up output
printf "$(tput setaf 5 2>/dev/null ||:)█$(tput sgr0 2>/dev/null||:)%.0s" $(eval echo "{1..${COLUMNS:-60}}")
echo
git push
}
-
ifn() {
- # insensitive find
+ local glob
+ glob="$1"
+ shift
+ find -L "$@" -not \( -name .svn -prune -o -name .git -prune \
+ -o -name .hg -prune -o -name .editor-backups -prune \
+ -o -name .undo-tree-history -prune \) -iname "*$glob*" 2>/dev/null
+}
+
+ifh() {
+ # insensitive find here. args are combined into the search string.
# -L = follow symlinks
find -L . -not \( -name .svn -prune -o -name .git -prune \
-o -name .hg -prune -o -name .editor-backups -prune \
# scp is insecure and deprecated.
scp() {
- rsync --inplace "$@"
+ rsync -Pt --inplace "$@"
}
ccomp rsync scp
# Convert brains file path to url and vice versa
# usage: brains [URL_OR_PATH]
brains() {
- _iki-convert /f/brains brains.fsf.org "$@"
+ _iki-convert '(/a)?/f/brains' brains.fsf.org "$@"
}
glue() {
- _iki-convert /f/gluestick gluestick.office.fsf.org "$@"
+ _iki-convert '(/a)?/f/gluestick' gluestick.office.fsf.org "$@"
}
# usage: $0 REPO_PATH [URL_OR_PATH]
_iki-convert() {
- local url path input err repo_dir domain filename dir path
+ local url path input err repo_dir domain filename dir path url_dir
local initial_oldpwd initial_pwd
repo_dir="$1"
domain="$2"
;;
*)
path=$(fp "$input")
- url="http*://$domain/wiki/${path#$repo_dir/}"
+ url_dir=$(echo "$path" | sed -r "s,^$repo_dir/,,")
+ url="https://$domain/wiki/$url_dir"
url="${url%.mdwn}/"
j echo "$url"
;;
# beet playlist. use beetag with a playlist name
bpl() {
local playlist playlist_regex
+ case $1 in
+ -h|--help)
+ for playlist in "${!bpla[@]}"; do
+ printf "%s\n" "$playlist"
+ done
+ return 0
+ ;;
+ esac
+
playlist="${*: -1}"
playlist_regex='[a-z0-9_]'
if [[ ! $playlist =~ $playlist_regex ]]; then
# shellcheck disable=SC2016 # obvious reason
tmpstr=$(beet ls -f "$fmt" "$@" | { if $random; then sort -R --random-source=$pl_seed_path; else cat; fi; } )
mapfile -t initial_ls <<<"$tmpstr"
+ if [[ ! ${initial_ls[0]} ]]; then
+ echo "beetag: error: no result from beet ls $*"
+ return 1
+ fi
id_count=${#initial_ls[@]}
for line in "${initial_ls[@]}"; do
path="${line#*PijokVipiotOzeph }"
feh() {
# F = fullscren, z = random, Z = auto zoom
- command feh -FzZ "$@"
+ command feh --auto-rotate -FzZ "$@"
}
arbtt-dump -l 30 -t json | jq -r '.[] | [ ( .inactive / 1000 | floor ) , ( .windows[] | select (.active == true) |.title) ] | @tsv' \
| tac | while read -r sec l; do
if (( i % 6 == 0 && i >= 2 )); then
- echo == $(( i / 6 + 1 )) ==
+ echo "## $(( i / 6 + 1 )) ##"
fi
if (( sec > 10 )); then
printf "%3d %s\n" $sec "$l"
}
ilogs-local() {
- cd /var/lib/znc/moddata/log/iank/freenode/
- hr
- for x in "#$1/"*; do
- base=${x##*/}
- files=()
- for f in $@; do
- tmp=\#$f/$base
- if [[ -e $tmp ]]; then
- files+=(\#$f/$base)
- fi
- done
- sed \"s/^./${base%log}/\" ${files[@]}|sort -n
+ d=/var/lib/znc/moddata/log/iank/
+ for n in freenode libera; do
+ cd $d/$n
hr
+ for x in "#$1/"*; do
+ base=${x##*/}
+ files=()
+ for f in $@; do
+ tmp=\#$f/$base
+ if [[ -e $tmp ]]; then
+ files+=(\#$f/$base)
+ fi
+ done
+ sed \"s/^./${base%log}/\" ${files[@]}|sort -n
+ hr
+ done
done
}
ilogs() {
chan="$1"
d=/var/lib/znc/moddata/log/iank/
for n in freenode libera; do
- cd $d$n/"$chan" && hr
+ if [[ ! -d $d$n/"$chan" ]]; then
+ continue
+ fi
+ cd $d$n/"$chan"
+ hr
for x in *; do
echo $x; sed "s/^./${x%log}/" $x; hr;
done
rg "$@" /p/w.org /a/t.org /a/work.org /b
}
+# re all my files more expansively
+rem() {
+ local paths
+ paths="/p/c /b"
+ find $paths -not \( -name .svn -prune -o -name .git -prune \
+ -o -name .hg -prune -o -name .editor-backups -prune \
+ -o -name .undo-tree-history -prune \) 2>/dev/null | grep -iP --color=auto "$*"
+ rgv -m 5 "$*" $paths ||:
+ }
+
+# setup:
+# pip3 install linode-cli
+# linode-cli
+livp9() {
+ local input ip id tmp
+ input=$1
+ if [[ $2 ]]; then
+ id=$2
+ ip=$3
+ else
+ tmp=$(mktemp)
+ echo $tmp
+ linode-cli --json --pretty linodes create --root_pass loxHuceygomGisun | tee $tmp
+ read -r ip id <<<"$(tail -n+2 $tmp | jq -r '.[0].ipv4[0] , .[0].id')"
+ for string in $ip $id; do
+ case $string in
+ [0-9]*) : ;;
+ *)
+ echo "livp9: bad value ip=$ip id=$id input=$input"
+ return 1
+ ;;
+ esac
+ done
+ rm $tmp
+
+ while true; do
+ if timeout 4 ssh $ip :; then
+ break
+ fi
+ sleep 3
+ done
+ fi
+ ssh $ip <<EOF
+apt-get -qq update
+apt-get -qq -y install ffmpeg rsync
+mkdir vp9
+EOF
+ m rsync $input $ip:
+ m ssh $ip ffmpeg -nostdin -hide_banner -loglevel error -i $input -g 192 -vcodec libvpx-vp9 -vf scale=-1:720 -max_muxing_queue_size 9999 -b:v 750K -pass 1 -an -f null /dev/null
+ m ssh $ip ffmpeg -nostdin -hide_banner -loglevel error -y -i $input -g 192 -vcodec libvpx-vp9 -tile-rows 2 -vf scale=-1:720 -max_muxing_queue_size 9999 -b:v 750K -pass 2 -c:a libvorbis -qscale:a 5 vp9/$input
+ rsync $ip:vp9/$input vp9
+ linode-cli linodes delete $id
+}
+
reset-konsole() {
# we also have a file in /a/c/...konsole...
local f=$HOME/.config/konsolerc
if type -P rg &>/dev/null; then
# --no-messages because of annoying errors on broken symlinks
# -z = search .gz etc files
- # -. = search dotfilesq
+ # -. = search dotfiles
rg() { command rg -. -z --no-messages -L -i -M 900 --no-ignore-parent --no-ignore-vcs -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || return $?; }
#fails if not exist. ignore
complete -r rg 2>/dev/null ||:
alias rg=grr
fi
+# rg with respecting vcs ignore files
+rgv() {
+ ret=0
+ command rg -. -z --no-messages -L -i -M 900 -g '!auto-save-list' -g '!.savehist' "$@" || ret=$?
+ return $ret
+}
# taken from default changes to bashrc and bash_profile