Skip to content

Instantly share code, notes, and snippets.

@markjaquith

markjaquith/gist:4500280

Last active Sep 7, 2016
Embed
What would you like to do?
Bash command to fix a quirk with Sublime Text 2's "subl" command. Sometimes, when using it, under hard-to-pinpoint circumstances, it will open up Sublime Text 2 completely blank (i.e. the file you asked it to open will not be open). This snippet fixes that by essentially kicking subl under the table to wake it up and then passing on the command …
function subl() {
if [[ ! -p /dev/stdin ]]; then
command subl > /dev/null 2>&1
fi
command subl "$@"
}
@n1k0

This comment has been minimized.

Copy link

@n1k0 n1k0 commented Jan 10, 2013

Thank you!

@damonjones

This comment has been minimized.

Copy link

@damonjones damonjones commented Jan 10, 2013

Awesome!

@tednaleid

This comment has been minimized.

Copy link

@tednaleid tednaleid commented Jan 10, 2013

Thanks, this was super annoying and seemed to happen about 1 out of 3 times (sometimes repeatedly.

@Teggy

This comment has been minimized.

Copy link

@Teggy Teggy commented Jan 31, 2013

Nice. I do think that checking whether standard input is redirected (i.e., stdin isn't the terminal but comes from a pipe or a redirected file) is more portably done via test -t 0. Thus

function subl() {
  if [[ -t 0 ]]; then
    command subl > /dev/null 2>&1
  fi
  command subl $@
}
@binarysprocket

This comment has been minimized.

Copy link

@binarysprocket binarysprocket commented Feb 15, 2013

Oh man, thank you so much for this. That used to be such a PITA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.