Skip to content

Instantly share code, notes, and snippets.

@madskjeldgaard
Created November 3, 2018 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madskjeldgaard/49a7babd4a64befc94a887213a46f4da to your computer and use it in GitHub Desktop.
Save madskjeldgaard/49a7babd4a64befc94a887213a46f4da to your computer and use it in GitHub Desktop.
startup script for scvim
#!/bin/bash
# SCVIM STARTUP SCRIPT
# By Mads Kjeldgaard
# --------------------
#
# Usage: bash <path/to/this/script> <optional/path/to/supercollider/file>
#
# Example: bash scvim_startup_script.sh cool_project.scd
#
# --------------------
# A startup script for SuperCollider, Vim and TMUX
# This will start a new Tmux session with Vim and the SuperCollider interpreter
# running inside of it.
#
# It will automatically create a .scd buffer with the name of the current date.
# Change this to wherever you have your SuperCollider code saved
# Default is ~/ aka your user directory
SCDIR=${SCDIR:-"/Users/madskjeldgaard/scripts/sc"}
TMUX=${TMUX:-"tmux"}
SESSION=${SESSION:-"SuperCollider"}
# Check for command line arguments
# First argument of the script is a path to a file
# If the argument is nil, it will create a new file
# in your standard directory defined in SCDIR
if [ -z "$1" ];
then
# If there is no command line argument passed
# Concatenate the directory path and the filename of the current file
FILE=${FILE:-$SCDIR"/_sessions/SC_$(date '+%y%m%d').scd"}
# echo "$SCDIR$(date '+%d%m%Y').scd"
else
# If there IS command line argument passed
FILE=${FILE:-"$1"}
fi
cd $SCDIR
# Start TMUX session with Vim, create a file and execute the SClangStart command
$TMUX attach-session -t $SESSION || $TMUX \
new-session -s $SESSION \; \
send-keys -t 0 "vim $FILE -R" C-m \; \
send-keys ":SClangStart" C-m \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment