Last Updated: February 25, 2016
·
393
· darkside73

Open Sublime Text from terminal

Handy shell script to open Sublime Text (or something else)
from terminal. Works in two modes:
- if no arguments passed - open new application window within current directory
- if argument passed:
* its new/existent file - open it in the current window
* its directory - open new window

Also you can use it even application not running without any outputs polluting terminal

#!/bin/bash

run_sublime () {
  if pidof sublime > /dev/null; then
    eval sublime $1
  else
    nohup sublime $1 > /dev/null 2>&1 &
  fi
}

if [ -z "$@" ]; then
  run_sublime '-n .'
else
  run_sublime $@
fi