gitmacoscoderunner

How to change default code editor for git as coderunner4 (a macos app) in MacOS


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.


Solution

  • 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 :

    git config core.editor '/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron'
    

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

    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 !