5

Some time ago I set up Sublime text 2 as my default editor for GIT in the command line terminal. I would now like to change it to LightTable, but am having some trouble. I have set both the VISUAL and EDITOR environment variables to LightTable and that does the trick for most extensions. But even though I set the .gitconfig file editor variable to LightTable as well, using several variations of this command:

git config --global core.editor "'/Applications/LightTable.app' -w"

and this one:

export GIT_EDITOR=LightTable

it is continuing to open .md files with sublime text 2. Other file extensions are also opening with TextEdit or other applications. Is there an easy way to rein in the chaos and set my default opening applications based on extension? I have read the man page for open and it mentions LaunchServices, but I can't find that on my hard-drive. I'm using bash with Unix(Darwin) on a mac running OSX. Thanks in advance!

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
kurofune
  • 1,055
  • 12
  • 26
  • 2
    This question is really off-topic for Stackoverflow (http://apple.stackexchange.com would be better) but the normal way to set LaunchServices associations is by selecting a file in the Finder, using the `Get Info` command, the `Open With` setting, and the `Change All` button. – Ned Deily Jul 01 '14 at 05:40
  • Sorry Ned. I am actually becoming less and less clear about what is an appropriate question for a given forum. Is there like an atlas or something that lays it all out? Also, is there a way to move the question to that forum instead of having to rewrite it out again? – kurofune Jul 01 '14 at 05:54
  • And thank you for this rocking answer. It pretty much solved the issue. I am still unclear as to how I could have done this from the terminal or specifically what variable where was causing it to open with Sublime Text 2 in the first place. – kurofune Jul 01 '14 at 05:57
  • Application bundles can specify what file types they are prepared to handle; they do so in their `Info.plist`. In the common case where more than one app is prepared to handle the same file type, it's a bit of a crap shoot which one wins; most likely, the app that was most recently installed. But it's kind of magic and magic that Apple has tweaked a number of times over the life of OS X. I believe you can change file type associations from the terminal but it's painful. – Ned Deily Jul 01 '14 at 07:12
  • WRT what's on topic here, check the help page: http://stackoverflow.com/help/on-topic – Ned Deily Jul 01 '14 at 07:14

2 Answers2

1

The problem is that /Applications/LightTable.app isn't an executable, it's an application bundle. You can double-click on application bundles from the Finder, but you can't run them from the terminal. See for yourself

$ /Applications/LightTable.app ./myfile.txt
zsh: permission denied: /Applications/LightTable.app

You will have to specify the full executable path, something like LightTable.app/Contents/MacOS/LightTable. I don't know exactly what it is.

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
  • 1
    Sure you can launch app bundles from the command line. That's exactly what the `open` command does. See `man 1 open`. – Ned Deily Jul 01 '14 at 05:42
  • [This](https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCIntro/LSCIntro.html) explains how LaunchServices, and by extension the open command, is able to handle bundles. But I am still not sure that 'being knowledgable about' and 'launching' are the same thing. I have just searched the LightTable.app directory and can't find a simple executable path that ends with `/LightTable`. – kurofune Jul 01 '14 at 05:50
  • In an OS X app bundle, the executable is specified in the app's `Info.plist`. The executable is normally found in `.app/Contents/MacOS/`. But that's not really germane to your question. – Ned Deily Jul 01 '14 at 07:21
0

I build a wrapper duti wrapper, called dutis , providing an interactive way to set default applications in command line.

You can set default applications using dutis within a few steps:

  1. Waiting for environment checking

enter image description here

  1. Selecting suffix

enter image description here

  1. Selecting application UTI

enter image description here

Tsonglew
  • 494
  • 1
  • 6
  • 17