Skip to content

Instantly share code, notes, and snippets.

@munshkr
Last active November 20, 2019 22:38
Show Gist options
  • Save munshkr/4cf8745a4983f3cd361826978481bd74 to your computer and use it in GitHub Desktop.
Save munshkr/4cf8745a4983f3cd361826978481bd74 to your computer and use it in GitHub Desktop.
Script for running TidalCycles from the command line (for Linux and macOS only)

TidalCycles wrapper script

This script wraps GHCI and loads TidalCycles using the bundled bootloading script. Only works on Linux and macOS.

Install

Run the following on your terminal

curl -sL https://gist.github.com/munshkr/4cf8745a4983f3cd361826978481bd74/raw/install-tidal-script.sh | bash -

This downloads and installs the tidal script on your system.

It also appends the following line at the end of your ~/.profile file, to make sure tidal can be found on your terminal:

export PATH=$HOME/.local/bin:$PATH

Usage

Run tidal to start the interpreter.

You can customize which bootloading script to use by setting TIDAL_BOOT_PATH to the path of your script. For a one-time use, run tidal like this:

TIDAL_BOOT_PATH=/path/to/my/script.hs tidal

To set it permanently, add this to your ~/.profile file:

export TIDAL_BOOT_PATH=/path/to/my/script.hs

License

MIT License

Copyright (c) 2019 munshkr

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#!/bin/bash
install_path=$HOME/.local/bin/
mkdir -p $install_path
curl -sL -o ${install_path}/tidal https://gist.github.com/munshkr/4cf8745a4983f3cd361826978481bd74/raw/tidal
chmod +x ${install_path}/tidal
echo "
# Add tidal script location to PATH
export PATH=$install_path:\$PATH" >> $HOME/.profile
echo "Added $install_path to your \$PATH in ~/.profile"
echo "Make sure to restart your terminal or run: source ~/.profile"
echo
echo -e "tidal installed! \xE2\x9C\xA8"
#!/bin/bash
set -euf -o pipefail
TIDAL_BOOT_PATH=${TIDAL_BOOT_PATH:-""}
# If Stack is installed, use stack exec to run ghci/ghc-pkg.
function runGhcCommand {
if [ $(command -v stack) ]; then
stack exec -- $@
else
$@
fi
}
if [ -z $TIDAL_BOOT_PATH ]; then
dataDir=$(runGhcCommand ghc-pkg field tidal data-dir --simple-output)
TIDAL_BOOT_PATH=${TIDAL_BOOT_PATH:-"$dataDir/BootTidal.hs"}
fi
# Run GHCI and load Tidal bootstrap file
runGhcCommand ghci -ghci-script $TIDAL_BOOT_PATH "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment