34

I just started using git about a month ago. It was set up for me using TextMate as my default editor for commits. However, I'd like to switch the default to TextWrangler which I already have installed. I looked around online and found a line of code to type into the terminal to do this. So I opened the terminal and typed:

cd Desktop
cd "projectName"
git config --global core.editor TextWrangler
git status
git add.
git commit  //then the error comes up

The error says: error: cannot run TextWrangler: No such file or directory error: There was a problem with the editor 'TextWrangler'. Please supply the message using either -m or -F option.

I don't know what this means or what I am doing wrong. I am sure its an obvious mistake, but can anyone explain how to fix this?

jac300
  • 5,182
  • 14
  • 54
  • 89
  • 2
    Dup of http://stackoverflow.com/questions/2596805/how-do-i-make-git-use-the-editor-of-my-choice-for-commits – Makkes Nov 06 '12 at 19:02

3 Answers3

50

Just answered my own question with the help of the above comments... to switch to TextWrangler as the default for Git, you must open TextWrangler, click on TextWrangler in the tool bar and select "install command line tools" from the drop down. Then go into command line and type:

git config --global core.editor "edit -w"

Edit is the command that is understood in the command line which means to open a textWrangler file.

jac300
  • 5,182
  • 14
  • 54
  • 89
  • Nice job and thanks for posting a follow-up! – thornomad Nov 20 '12 at 19:43
  • 4
    From a deleted answer (shouldn't have been an answer, but the info seems useful nonetheless): If you downloaded TextWrangler from the Apple Store, then you don't have the option to "install command line tools". You have to visit http://www.barebones.com/support/textwrangler/faqs.html#cmdlinetools to download the tools. – ptomato Sep 13 '13 at 00:44
  • 1
    In case anyone's wondering where the Command Line Tools option is located, it's been removed from the App Store version of TextWrangler. But you can get it from here: http://pine.barebones.com/files/tw-cmdline-tools-453.zip – Sridhar Sarnobat Oct 01 '13 at 18:18
  • Can you explain what the `-w` option does? and what it stands for? – chharvey May 30 '14 at 04:10
  • @chharvey ``-w`` waits until the file is closed in TextWrangler. Normally, the edit tool exits immediately after the file arguments are opened in TextWrangler. Git just aborts if ``-w`` is not passed, so it won't work otherwise. See ``man edit`` for more info. – Lucio Paiva Oct 15 '14 at 01:57
  • 1
    I've got TextWrangler from the Mac app store installed, and I got it to work without installing the command line tools. Just use "open -n -W -a TextWrangler" and make sure your "TextWrangler > Preferences > Application > When TextWrangler becomes active:" setting is set to "Do nothing" – DLRdave Apr 15 '16 at 12:52
  • If you are using TextWrangler from AppStore, just follow this page http://www.barebones.com/support/textwrangler/cmd-line-tools.html – Igor Kislyuk Oct 10 '16 at 13:07
5

Follow-up to @thornomad

Command for changing editor in Git is (one of possibilities)

git config --global core.editor "mate -w", there string inside quotes marks is full command-line for invoking editor from terminal

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • ok, so that line just worked to set it back to text mate, but then I tried to set it to text wrangler: git config --global core.editor "TextWrangler -w" and got the error again. I also tried variations of 'TextWrangler' (i.e. "wrangler", "Text Wrangler," etc.) and none worked... – jac300 Nov 06 '12 at 19:20
3

Are you on a Mac ? If you run TextWrangler from the command line (Terminal.app) does TextWrangler open?

My guess is that git is expecting you to pass it the name of an executable that is in your PATH ... I would also guess that TextWrangler is not (this is just a guess, no experience with it).

Try changing core.editor to vim and see if you still get the error.

Also - check out this thread (it may help).

Community
  • 1
  • 1
thornomad
  • 6,707
  • 10
  • 53
  • 78
  • yes on a mac. I'm not very experienced with using the terminal either, so I am not sure how to open TextWrangler from command line but can figure it out and see if that's the issue. Meanwhile, I used the answer below which successfully allowed me to use text mate again, but same code with text wrangler doesn't work. still dont know why – jac300 Nov 06 '12 at 19:23
  • thanks, your answer just helped me figure it out - the version of text wrangler I had did not have the proper command line tools installed, so the command "textWrangler" was not recognized. Had to update to BBEdit. – jac300 Nov 06 '12 at 19:37
  • I added a link that may help you with TextWrangler. – thornomad Nov 06 '12 at 19:50