I recently bought a new MacBook. One of first things you’ll want to do when setting up a new machine is configuring git to your liking. While I used to be a heavy vim user, a year or so ago I switched to Sublime Text (ST) for writing messages. I thought I’d document the steps for this configuration as I take them myself.

I tested the instructions below on MacOS 11.4, Big Sur.

Configuration steps

  1. Install ST, following the ST documentation. In my case, it was downloading a zip file, unzipping the file and dragging the ST application into my Applications folder.
  2. Verify that you can launch ST by double-clicking the ST icon in the Applications folder. ST should open in the new window. Close this window.
  3. Configure ST to be accessible from the terminal, following ST documentation. In my case, it was running:
     echo 'export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"' >> ~/.zprofile
  4. Verify that you can launch ST from the terminal. Open a new terminal and run subl --new-window. ST should open in a new window.
  5. Set ST as your git editor, running
    git config --global core.editor "subl -n -w"

Testing configuration

  1. Open a new terminal.
  2. Run the following:
    git init repo-1
    cd repo-1
    touch file-1
    git add file-1
    git commit
  3. After the last command above, verify that ST launches in a new window.
  4. Complete the commit, by writing “Add file-1”, saving (⌘+S), and closing the window (⌘+W).
  5. Verify that ST closes, and the terminal shows something like:
    [master (root-commit) 2ca0638] Add file-1
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 file-1