jdunic / Intro-To-Practical-Computing-R

This repository supports the website for the 'BIOL 653 - intro to practical computing in R' for UMass Boston.
http://r.jillian.io
6 stars 0 forks source link

Launching TextEdit from git #6

Open bseitz234 opened 9 years ago

bseitz234 commented 9 years ago

git is giving me an error when it tries to launch TextEdit, and I'm wondering if someone might be able to help me out with it:

First I tried the simple command that was in the walkthrough to make TextEdit the editor: git config --global core.editor "TextEdit -w"

which returned:

TextEdit -w: TextEdit: command not found
error: There was a problem with the editor "TextEdit -w".

So I got a little more specific:

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

and if I try a commit without a message, it returns the error message:

$ git commit
/Applications/TextEdit.app -w: /Applications/TextEdit.app: is a directory
error: There was a problem with the editor '/Applications/TextEdit.app -w'.
Please supply the message using either -m or -F option.

(As long as I include a message with -m, it doesn't bother with TextEdit and everything works just fine)

On a whim, I tried without the -w, and got

fatal: cannot exec '/Applications/TextEdit.app': Permission denied
error: unable to start editor '/Applications/TextEdit.app'

And I think that's where I'm at... any ideas?

Thanks in advance!

jdunic commented 9 years ago

That is definitely my bad! Try it all lowercase and let me know if that fixes it.

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

I'll update the webpage now!

bseitz234 commented 9 years ago

Unfortunately, still not working. What's odd is that if I leave git out of it: $ open "/Applications/TextEdit.app" works fine.

with or without git, I get the "command not found" unless I specify to look in the /Applications folder.

$ git commit
textedit -w: textedit: command not found
error: There was a problem with the editor 'textedit -w'.
Please supply the message using either -m or -F option.

$ open textedit or $ open textedit.app or $open TextEdit.app .... or even just $ textedit all return command not found.

bseitz234 commented 9 years ago

Updated 5:00pm: So, how deep down the rabbit hole do you want to go on here, and/or would it be easier to skip TextEdit entirely and remind myself how to use emacs?

If I'm very explicit: git config --global core.editor "/Applications/TextEdit.app/Contents/MacOS/TextEdit -w" I can get TextEdit to start up in the background, but it doesn't actually give me a window to enter a commit message. Might need to play with more flags to make that happen.

I can get TextEdit to open and give me a window with: git config --global core.editor open (uses the default system application for plain text, which in my case is TextEdit). Success!

...but, as soon as TextEdit opens, before I have a chance to type and save a commit message, I get

$ git commit
Aborting commit due to empty commit message.

because git isn't waiting for it. If I try to add the -w flag, bash gets mad because open doesn't accept that flag.

jdunic commented 9 years ago

What happens when you include a commit message? E.g.,

git commit -m 'testing out commit with message'

By default, git requires a commit message to enforce best practices in using version control. Commit messages should be concise but meaningful; generally a brief explanation of why a change was made, rather than what was done since you can just look at the change directly.

The real test of whether the TextEdit business will work will be when we have to do a merge commit.

I like knowing about the core.editor open option! I'll add that to the list.

bseitz234 commented 9 years ago

As long as I give it a message, it works just fine- it's just when it tries to open an external text editor to do a longer commit message.

It also works fine with emacs:

git config --global core.editor emacs

when I commit, launches emacs, where I can enter a message, save it, and quit emacs and come back to this:

$ git commit 
[master f9efc80] The horses are magical.
 1 file changed, 1 insertion(+), 1 deletion(-)

Also, open works best for me if I use it with -W -n as options:

$ git config --global core.editor "open -W -n"

(source and explanation of options: http://stackoverflow.com/questions/6435246/trouble-on-setting-the-git-core-editor)

it seems to only give me trouble if I try to refer to text edit explicitly, which is weird, and I'd like to know what's causing it.... but I'm OK with either using open or emacs, so I think I'm good for now!

jebyrnes commented 9 years ago

I wonder if this has something to do with opening a text editor external to the shell? This is why emacs or nano or somesuch works normally.

bseitz234 commented 9 years ago

I was curious about that as well... but it does strike me as odd that it works with open but not with calling TextEdit explicitly, even if I use the -W -n flags.

klarraga commented 9 years ago

What is TextEdit? Did I miss the class when this was covered? Oops.

bseitz234 commented 9 years ago

I think we went over it pretty quickly... I wouldn't worry about this too much for now, as long as you include a message in your commits ( git commit -m "I made my commit for some reason that I describe here").

But, if you're curious: TextEdit is a simple, plain text editing program. The context of this issue is that git won't let you make a commit without a message explaining why. If you don't include one with the -m flag, you can tell git to open a small message file in a text editor, where you can leave a longer, more detailed message. TextEdit is the built-in text editor on Macs, which has a nice simple graphical user interface. There are lots of other alternatives that are on the command line, but those can be a bit trickier to use.

Takeaway: I think $ git config --global core.editor "open -W -n" should be all you need to set this up, and should work going forward.