Last active
March 14, 2020 01:36
-
-
Save mattriley/5e5983107e5f81e4e982f34a97eb63b1 to your computer and use it in GitHub Desktop.
Clones and runs a script from a GitHub gist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: ./run-gist.sh <GIST ID> <SCRIPT NAME> <SCRIPT ARGS> | |
# Extract args | |
gist_id="$1" | |
script_name="$2" | |
script_args="${@:3}" | |
# Clone gist | |
remote="https://gist.github.com/$gist_id.git" | |
gist_dir=".gist/$gist_id" | |
mkdir -p "$gist_dir" | |
git clone "$remote" "$gist_dir" 2> /dev/null || git -C "$gist_dir" pull | |
# Run gist script | |
script_path="$gist_dir/$script_name" | |
chmod +x "$script_path" | |
"$script_path" "$script_args" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment