Skip to content

Instantly share code, notes, and snippets.

@kylegarcher
kylegarcher / shell_args.sh
Created June 11, 2022 20:49
Parsing shell arguments
#!/bin/bash
# From https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
while [[ "$#" -gt 0 ]]; do
case $1 in
-t|--target) target="$2"; shift ;;
-u|--uglify) uglify=1 ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
@kylegarcher
kylegarcher / rclone_warn.sh
Last active June 11, 2022 17:54
Warn if rclone remote destination becomes too large
#!/bin/sh
CLOUDDEST="<remote destination>:/"
RCLONE_WARNING_SIZE_GB=500 # Replace as desired
RCLONE_ALERT_SIZE_GB=1000 # Replace as desired
echo "Checking Rclone remote size ($CLOUDDEST)"
rclone_size="$(rclone size --json $CLOUDDEST)"
rclone_size_bytes="$(echo $rclone_size | jq '.bytes')"
@kylegarcher
kylegarcher / git_ssh_key.sh
Last active June 10, 2022 09:18
Specify SSH key for git
# If the repository has already been cloned/initialized
# First, cd to the folder containing the project of interest
# Then, execute the following:
git config core.sshCommand "ssh -i <path to SSH key>"
# If the repository has NOT yet been cloned:
git clone git@github.com:<username>/<repo name> --config sshCommand "ssh -i <path to SSH key>"
@kylegarcher
kylegarcher / count.sh
Last active June 9, 2022 21:18
Count number of files and subdirectories in a directory
du ./* -s --inodes | sort -rh