header

quick commands I often need

compile some latex on source modification, while zathura is showing it

fswatch --event Updated -o "$1" | xargs -n1 -I{} xelatex --shell-escape -interaction batchmode "$@"

image sequence to mp4

ffmpeg -r 24 -i %04d.png -vcodec libx264 -crf 20 -pix_fmt yuv420p output.mp4

mp4 to image sequence

ffmpeg -i video.webm image-%03d.png

start an http server from current directory

python3 -m http.server

set the keyboard up

setxkbmap "$@" setxkbmap -option "caps:swapescape" setxkbmap -option keypad:pointerkeys xset r rate 150 110& xmodmap -e "keycode 135 = Super_R" xmodmap -e "keycode 230 = Menu"

generate a password

openssl rand -base64 32

scroll with middle mouse pushed

xinput set-prop "TPPS/2 Elan TrackPoint" "libinput Scroll Method Enabled" 0 0 1 xinput set-prop "Logitech USB Optical Mouse" "libinput Scroll Method Enabled" 0 0 1 ### to go back to "normal" # xinput set-prop "TPPS/2 Elan TrackPoint" "libinput Scroll Method Enabled" 0 0 0 # xinput set-prop "Logitech USB Optical Mouse" "libinput Scroll Method Enabled" 0 0 0

xelatexwatch (to automatically recompile a latex file upon modification)

fswatch --event Updated -o "$1" | xargs -n1 -I{} xelatex --shell-escape -interaction batchmode "$@"

quickly run in parallel

N=8 PROGRAM=$1 shift for thing in $@; do ((i=i%N)); ((i++==0)) && wait $PROGRAM $thing & #task "$thing" & done

invert pdf colors

IN=$1 OUT=$(basename $1 .pdf)-inverted.pdf if [ -f "$OUT" ]; then echo "$OUT" already exists else convert -density 192x192 "$IN" -density 192x192 -negate -compress zip "$OUT" fi

the original pdfbook which seems simpler, faster and better than pdfbook2

#!/bin/sh ## ## pdfbook: Rearrange pages of one or more PDF files into 2-up signatures ## ## Author David Firth (http://go.warwick.ac.uk/dfirth), with help ## from Marco Pessotto ## ## This is a simple wrapper for pdfjam, version 2.08 ## case $1 in --short-edge) shortedge=true ; shift ; ;; *) ;; esac for arg do case $arg in --signature*) ## catches both --signature and --signature* signature=true ; break ;; *) ;; esac done ## ## If $signature is empty, we need to use a default: ## if test -z "$signature" ; then signature="--signature 4" else signature="" fi ## ## Make the call to pdfjam: ## if test -z "$shortedge" then exec pdfjam --booklet true --landscape --suffix book $signature "$@" else (kpsewhich everyshi.sty >/dev/null) || { echo "the 'everyshi' package is not installed."; exit 1 } exec pdfjam --booklet true --landscape --suffix book $signature \ --preamble '\usepackage{everyshi} \makeatletter \EveryShipout{\ifodd\c@page\pdfpageattr{/Rotate 180}\fi} \makeatother ' "$@" fi