Collection of scripts I use often. Installation:
-
Clone the repo somewhere (eg.
~/code/scripts):git clone --depth 1 https://github.com/wzulfikar/scripts ~/code -
Add the scripts into your
PATH(eg. in~/.bashrcor~/.zshrc):GH_SCRIPTS=$HOME/code/github/scripts export $(grep -v '^#' $GH_SCRIPTS/.env | xargs) # load env vars export PATH=$GH_SCRIPTS:$PATH
-
Run
eqfor test run (it checks if two values match):eq 123 123
-
Use
hash ...to check dependencies before running the script:hash gh 2>/dev/null || { echo "ERROR: missing dependencies: 'gh'" && exit 1; } # check dependencies # ... run the actual script
-
Use
MISSING_DEPSto check multiple dependencies:# check dependencies hash convert 2>/dev/null || { MISSING_DEPS="$MISSING_DEPS convert"; } hash tesseract 2>/dev/null || { MISSING_DEPS="$MISSING_DEPS tesseract"; } [ ! -z "$MISSING_DEPS" ] && echo "ERROR: missing dependencies: ${MISSING_DEPS}" && exit 1 # ... run the actual script
Example:
ocr -
Use
$(basename $0)to display the script name:if [ -z "$1" ] || [ "$1" = "-h" ]; then echo "$(basename $0) – converts given file (.mov, .gif, etc.) to .mp4 using ffmpeg." # ... fi