Skip to content

Instantly share code, notes, and snippets.

@r2rien
r2rien / ff.sh
Created April 26, 2020 00:11
'find' GNU cheatsheet/wrapper with shorter '-prune' arg: ff /run -p /run/user,/run/udev -name '*control*'
#!/bin/sh
THIS=$(basename $(realpath $0))
USAGE="'find' GNU cheatsheet/wrapper
* for quicker/simpler '-prune' switch mecanism, avoiding traversing unwanted directories,
* while having a quick toggling of 'permission denied' errors to /dev/null
/!\ without playing/falling in '! -readable' trap
usage:
${THIS} /path/to/search [${THIS} OPTIONS] [any other 'find' args, ex: -name '*pattern*']
-h | -help | --help : print this help and exit
-e : don't redirect stderr to /dev/null
@r2rien
r2rien / wmx.wrapper
Created February 3, 2016 01:06
wmx wrapper
#!/bin/sh
## wrapper to window manager focus an already running software or execute it
BIN_NAME=$(basename $0)
WM_CLASS=$BIN_NAME.$(echo "$BIN_NAME" | sed 's/.*/\u&/') # capitalise BIN_NAME
[ $# -gt 0 ] && BIN_ARGS="$@"
#~ echo wmx -c $WM_CLASS -b /usr/bin/$BIN_NAME $BIN_ARGS
wmx -c $WM_CLASS -b /usr/bin/$BIN_NAME $BIN_ARGS
@r2rien
r2rien / wmx
Last active April 25, 2020 15:59
wmctrl wrapper
#!/bin/sh
## window manager focus an already running software / iconify it / run it / pass it args :: r2blue=6E9AD7
USAGE="
Usage: $(basename $0) -c WM_NAME [-e] [-a] [-i] [-f NAME_FOCUS] [-v NAME_PRUNE] [-b BIN_PATH] [BIN_ARGS]
-e check only (returning window hex id if running)
-a do not limit to user($(whoami)) when checking window hex id
-u when already running, bypass any provided args (focus only)
-g switch to next window with same class (focus only)
-f NAME_FOCUS : targeted title window name
-v NAME_PRUNE : comma separated list of title window names to exclude