Skip to content

Instantly share code, notes, and snippets.

@jbflow
Last active December 14, 2023 05:10
Show Gist options
  • Save jbflow/28c8df37d6e93ccedae526c0e058f9ba to your computer and use it in GitHub Desktop.
Save jbflow/28c8df37d6e93ccedae526c0e058f9ba to your computer and use it in GitHub Desktop.
Copies a MIDI Remote Script from a working git repo into Ableton Lives Remote Scripts folder in the User library. Creating folders as necessary, excluding .git repo and has overwrite protection.
#!/bin/sh
# Run the following commands to add to your terminal
# sudo cp copy_remote_script.sh /usr/local/bin
# cd /usr/local/bin
# chmod +x copy_remote_script.sh
# now from your remote script directory you can run 'sh copy_remote_script.sh . <SCRIPTNAME>' And it will do everything for you.
# If you want to shorten it you can add an alias
# cd ~/.
# vim .zshrc
# alias cprs="sh copy_remote_script.sh"
# Now you can do cprs . <SCRIPTNAME>
SRC=$1
REMOTE_SCRIPT_DIR="$HOME/Music/Ableton/User Library/Remote Scripts"
DEST="$REMOTE_SCRIPT_DIR/$2"
# Checks for arguments
if [ ! "$1" ] || [ ! "$2" ];
then
echo "Please supply a source and destination directory as command line arguments"
exit
fi
# Creates the Remote Script dir
if [ ! -d "$REMOTE_SCRIPT_DIR" ]; then
echo "Remote Scripts directory not found... Creating"
mkdir "$REMOTE_SCRIPT_DIR"
fi
# Creates tbe script dir
if [ ! -d "$DEST" ];
then
echo "Script Does not exist. Creating empty directory."
echo "Creating $2 in $REMOTE_SCRIPT_DIR"
mkdir "$DEST"
echo "Copying files"
else
# Asks to overwrite the script
echo "[WARNING] Script exists, are you sure you want to overwrite? This cannot be undone! [yes/no]"
while true
do
read OVERWRITE
if [ "$OVERWRITE" = "no" ]
then
echo "Exiting..."
exit
elif [ "$OVERWRITE" = "yes" ]
then
echo "Overwriting files"
break
else
echo "[ERROR] Didn't detect a valid entry. Should I overwrite the script at $DEST? [yes/no"]
fi
done
fi
# Copies the files across
sudo rsync -av --exclude=".git" "$SRC/." "$DEST"
echo "Done"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment