git-core-editor is a Git editor wrapper for commit messages.
It chooses an editor in this order:
- If the shell was launched from a JetBrains IDE such as PyCharm, it uses the IDE command-line launcher with
--wait. - If a GUI Emacs server is already running, it uses
emacsclient. - Otherwise, it falls back to
emacs -nw.
Run the script with --install and pass the directory where you want the command installed:
bash /Users/haroonkhan/projects/git-editor-shell-script/git-core-editor.sh --install ~/.local/binThis will:
- Create the target directory if it does not exist
- Copy the script to
DIR/git-core-editor - Mark the installed copy as executable
If the install directory is not already on your PATH, add it in your shell startup file:
export PATH="$HOME/.local/bin:$PATH"For Bash on macOS, add that line to ~/.bash_profile or to whatever startup file your shell loads.
After updating your startup file, reload it or open a new shell.
Point Git at the installed command:
git config --global core.editor "$HOME/.local/bin/git-core-editor"You can confirm the setting with:
git config --global --get core.editorIf you change git-core-editor.sh, run the install command again to copy the latest version over the installed command:
bash /Users/haroonkhan/projects/git-editor-shell-script/git-core-editor.sh --install ~/.local/bin- For IDE editing, install a JetBrains command-line launcher such as
charm,pycharm, oridea. - For GUI Emacs editing, run an Emacs server that
emacsclientcan connect to. - If neither is available,
emacs -nwmust be installed.