Skip to content

Instantly share code, notes, and snippets.

@tornewuff
Created January 16, 2013 00:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tornewuff/4543518 to your computer and use it in GitHub Desktop.
Save tornewuff/4543518 to your computer and use it in GitHub Desktop.
Script to wrap Sublime Text 2 on Linux, handling proper background invocation and using rmate to edit remotely when not in an X session (the guess being that if there's no DISPLAY we are connected via ssh).
#!/bin/bash
if [ -z "$DISPLAY" ]; then
exec rmate "$@"
fi
for arg do
case $arg in
"-w" | "--wait") NEED_FOREGROUND=1;;
"-h" | "--help") NEED_FOREGROUND=1;;
"-v" | "--version") NEED_FOREGROUND=1;;
esac
done
if [ -n "$NEED_FOREGROUND" ]; then
exec sublime_text "$@"
else
exec sublime_text "$@" </dev/null >/dev/null 2>/dev/null &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment