#!/bin/bash

# If sublime is not running, check if we should clean the session
if ! pgrep -x subl > /dev/null
then
    sublime_session_clean.py --program text
fi

# Run with our arguments
subl $*

#!/usr/bin/env bash

#
# This is meant to be invoked from the task bar or a launcher in order to start
# Sublime; any arguments passed to the script are passed to Sublime when it's
# launched.
#
# A check is done prior to the launch to see if Sublime is currently running or
# not. If it's not, then a check is done to see if there are any defunct
# projects in the session that can be cleaned up.
#
# Once the check (if any) is complete, Sublime is launched.
#
# Additionally, if Sublime was already running, -n is added to the list of
# arguments so that running the script while Sublime is already running creates
# a new window.
#
# Regardless, Sublime is started and passed all of the arguments the script
# received.

#
# Check to see if Sublime is running or not.
#
if ! pgrep -x sublime_text > /dev/null
then
    #
    # Sublime is not running, so run a check to clean the session and then
    # start Sublime with the arguments we were given.
    #
    sublime_session_clean.py -p text --workspaces --files --folders
    sublime_text $*
else
    #
    # Sublime is currently running. In that case execute with the arguments
    # that we were given, but also include -n so that a new window is created.
    #
    sublime_text -n $*
fi


Update the sample script file
Update the sample script file

This updates the sample script file to include new options for what to
clean up when Sublime is launched. In addition this also includes the
notion (which is easily disable-able if desired) that running the script
while Sublime is running will create a new window, which makes taskbar
buttons for this nicer to use.

We also now find bash without hard coding it, for use on systems that
might have custom bash versions installed in non-standard locations.
