0

I am using a code editor named as CodeRunner 4 from Mac App store. I want to set it as default code editor in git, so that when I want to do some changes in files or adding a commit message, terminal will open this default code editor for me.

I tried on my own by doing

git config --global core.editor "coderunner4 --wait"

but nothing opens when I tried doing git commit, instead this error message shown :

Aayushs-MBP: projectd/ $ git commit
hint: Waiting for your editor to close the file... coderunner4 --wait: coderunner4: command not found
error: There was a problem with the editor 'coderunner4 --wait'.
Please supply the message using either -m or -F option.

It says that there is no command like coderunner4. I don't know how to find command which is set by developer to open this app. I also tried to make default editor as Visual Studio Code by doing this :

git config --global core.editor "code --wait"

but same error message shown again when I tried to git commit upon which it should open default git editor for adding commit message :

Aayushs-MBP: projectd/ $ git commit
hint: Waiting for your editor to close the file... code --wait: code: command not found
error: There was a problem with the editor 'code --wait'.
Please supply the message using either -m or -F option.

I think there might be a problem regarding .bash_profile in which I have to set a path for applying commands like coderunner4 [for coderunner] and code [for vs code] So I also modified .bash_profile by adding this snippet from SO :

code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}

but nothing happened

I also tried to change the default editor by giving full path but again the slightly different error message shown :

Aayushs-MBP: projectd/ $ git config core.editor './Applications/CodeRunner.app --wait'
Aayushs-MBP: projectd/ $ git commit
hint: Waiting for your editor to close the file... ./Applications/CodeRunner.app --wait: ./Applications/CodeRunner.app: No such file or directory
error: There was a problem with the editor './Applications/CodeRunner.app --wait'.
Please supply the message using either -m or -F option.

Please help me to change my default code editor as CodeRunner 4 for git.

Aayush Shah
  • 584
  • 1
  • 8
  • 17
  • It's looking for a command line tool. Does coderunner have one? – matt Sep 26 '21 at 13:28
  • @matt I searched on google but I didn't find any details regarding that. That's why I gave developer and app link also ! – Aayush Shah Sep 26 '21 at 13:49
  • Also note that `./Applications/CodeRunner.app` is not a valid path for where the app is. – matt Sep 26 '21 at 13:51
  • Possible solution: [Launch an app on OS X with command line](https://stackoverflow.com/questions/1308755/launch-an-app-on-os-x-with-command-line) – Richard Smith Sep 26 '21 at 14:08
  • @matt then what it is? I copied that from finder itself! – Aayush Shah Sep 26 '21 at 14:35
  • @RichardSmith No no, I don't want to launch editor or an app. I wan't to open the file in code editor which git recommends me to modify ! – Aayush Shah Sep 26 '21 at 14:36
  • I would describe it as `/Applications/CodeRunner.app/Contents/MacOS/CodeRunner`. Note the lack of the initial dot, plus we need to reach the executable. This might succeed in launching CoreRunner when Git needs an editor, but that will _not_ make CodeRunner well behaved with regard to Git if it isn't already. Further experimentation may be needed. Personally I think you'd be much better off using BBEdit (the freeware version will do fine). Reduce it to a previously solved problem... :) – matt Sep 26 '21 at 14:51
  • Thank you @matt your suggestion worked but it only opened the empty code editor! it didn't opened the file in which I have to write the commit message or something else :( I think we have to provide some additional attributes/arguments along with the config command ! – Aayush Shah Sep 26 '21 at 20:24
  • 1
    Yeah, I'm not sure we can make it work at all. BBEdit BBEdit! – matt Sep 26 '21 at 20:38
  • @matt Thanks a ton! I figured it out finally only because of your idea !! I gave the answer below in detail. also I will try your suggested editor BBEdit and let you know how it goes :) – Aayush Shah Sep 26 '21 at 20:50

1 Answers1

0

Thanks to @matt, I figured out by twisting and tweaking that coderunner app doesn't support this type of file which git uses while editing commit messages and other stuffs so that whenever git attempted to open file for writing commit message, coderunner app is simply opens empty (no file is opened for editing).

So, I tried to set another default code editor for writing out these stuff in git which opens directly through terminal. I chose VS code to open default code editor in git. Here are the steps :

    1. Open Finder and go to applications folder
    1. Search for your code editor which you want to set as default editor for git.
    1. Right click on it and chose Show Package Contents
    1. Go to Contents/MacOS/ and select the executable file which is located here. Then copy the path of this executable file. In my case, when I chosen VS Code : it was /Applications/Visual Studio Code.app/Contents/MacOS/Electron
    1. Open terminal and configure VS code as your default code editor by this command :
git config core.editor '/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron'

Remember to put \ before the space if your app name contains any!

    1. You're done! see your default git code editor by this command :
git config core.editor

Now, whenever git wants you to edit changes/ add commit message, VS Code or any deafult code editor will open automatically and the file contents will be there. You simply go through them/ modify them. As soon as your quit your editor, git will continue its work in terminal !

Aayush Shah
  • 584
  • 1
  • 8
  • 17
  • If you use `--wait` you might not have to quit, just close the document. – matt Sep 26 '21 at 21:48
  • @matt yeah I thought that too! and also tried to close the document but terminal didn't recognized that I have closed the doc! so... – Aayush Shah Sep 27 '21 at 03:35