Setting up a Mac Laptop for a Software Engineer Coming from a Linux Desktop

I’ve recently started a new job and am setting up a MacBook Pro M4. I’ve been using either a native Linux Desktop, or a Linux Desktop as a VM on a Windows box for most of my career. There are a number things about the Mac that are different than Intel based machines running Linux following are the list of changes that I have made to make it usable as a development environment.

Show all files in an “Open” dialog box

Press Cmd + Shift + .

Set system time to UTC

sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime

To display time in seconds go to System Settings > Menu Bar > Clock and select “Display the time with seconds”

If you also want to display a clock that shows your local time install Clocker.

Disable the “Press and Hold” Feature

By default, holding down a given key will display a pop-up/tooltip that displays accented version of the given character. I use a Vim plugin with the IDEs that I use and when trying to navigate by holding down either the w or b chars the cursor only moves by one work and then shows an accented character. To disable it

  1. Run the following command in a terminal and then restarting applications. This turns off the feature that will show accented characters: defaults write -g ApplePressAndHoldEnabled -bool false
  2. Turn up the Key Repeat rate by going to System Setting > Keyboard and adjust the slider for the “Key repeat rate”. If this still feels too slow you can crank it up with the following terminal settings which enable values much lower than the UI allows to be set
# Sets a very short delay before repeating
defaults write -g InitialKeyRepeat -int 15 

# Sets a very fast repeat rate
defaults write -g KeyRepeat -int 2

Configuring Home and End Keys

  1. Create the following directory: mkdir -p ~/Library/KeyBindings
  2. Create and edit the binding file vi ~/Library/KeyBindings/DefaultKeyBinding.dict
  3. Paste the following content into it
{
    "\UF729" = "moveToBeginningOfLine:";
    "\UF72B" = "moveToEndOfLine:";
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:";
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";
}

Then save and close that file and restart applications and/or restart the Mac.

iTerm2 Specific Configurations

Configure Home and End keys to work properly

  1. Go to Settings > Profiles > Keys > Key Bindings and click the + at the bottom left.
  2. For the Home Key:
    • Keyboard Shortcut: Press your physical Home key.
    • Action: Select Send Hex Code.
    • Code: 0x01 (This is the hex for Ctrl+A).
  3. For the End Key:
    • Keyboard Shortcut: Press your physical End key.
    • Action: Select Send Hex Code.
    • Code: 0x05 (This is the hex for Ctrl+E).

Configure F-keys to work without pressing fn

  1. Open System Setting > Keyboard and click on Keyboard shortcuts
  2. Click on Function Keys in the left-hand nav
  3. Toggle the Use F1, F2, etc. keys as standard function keys

Getting Alt-Tab to Switch Applications

Download and install the AltTab application.

Configuring Primary Selection and Middle Click Paste

One of the things that I use all of the time under Linux is to select text and then middle-click to paste it. This is one of those Linux features that once you get used to, you just have to have.

Configure iTerm2

  1. Open iTerm2 settings
  2. Go to General > Selections
  3. Check the box “Applications in terminal may access clipboard”
  4. Check the box “Copy to clipboard on selection”
  5. Go to Pointer > Bindings
  6. If “Middle Button” is not there, click the “+” button at the bottom of the window
  7. Set the following
    • Button/Gesture: Middle Button
    • Click Type: Single Click
    • Action: Paste from Selection…: There are a whole host of additional options from there that you can choose from. I left the default settings.

Install BetterTouchTool

In order to get the primary selection and middle click paste in the rest of the OS this seems to be the best option. I downloaded the trial first to see if it will work and configured it as follows

  1. Open BTT
  2. In the top of the window is a dropdown. By default it said “Touch Bar“. Click on it and select “Normal Mouse
  3. On the LHS ensure that “For All Apps” is selected
  4. For Middle-Click Paste
    • Click on the “+” under “Add first Normal Mouse Trigger for All Apps” in the main section of the window
    • In the right-hand panel that appears, hover the mouse over the “Click to record custom mouse button” and click the middle mouse button. The text inside that button should now say “Middle Mouse Button”
    • Then in the middle window click the “+” below text that says “Please click below to select button”
    • Then, to the right of that, click on the “+ Add First Action”
    • This will change the far-right column with at title of “Action Configuration”
    • Click on the “No Action” dropdown and select “Send Keyboard Shortcut” and then press Command-V to define the paste action.
  5. For Copy on Select
    • Select “Automations & Named & Other Triggers” from the top dropdow
    • Click the + in the middle column again.
    • Search for the trigger: “Text Selection Did Change”.
    • In the right-hand column (Actions), click + and add the “Copy Text Style/Formatting” action.
  6. Blacklist iTerm2
    • Click on the “+” at the bottom of the LHS nav and add iTerm2
    • Select iTerm2 from the side nav
    • In the far RHS nav, ensure that you just have iTerm2 selected, select Disable BetterTouchTool completely so that the configs in iTerm2 do not conflict with BTT configs.

Screenshots

Configure the OS to write screenshots to a specific directory

# Set the new location
mkdir -p $HOME/Pictures/Screenshots
defaults write com.apple.screencapture location $HOME/Pictures/Screenshots

# Apply the changes (restarts the UI server)
killall SystemUIServer

Additional brew Packages

  • watch

Development SDKs

Installing Go

Initially, I just went with brew install go, but this turned into a big mess. While working on a project where I was writing a K8s Custom Resource Definition I ran into a buzz saw of mismatched versions and edge cases with the Apple Silicon/ARM architectural problems with the go development toolchain.

Instead of using brew for the go SDK

  1. Download the .pkg file from https://go.dev/dl/ and install it
  2. Install any other required go libraries with go install or by downloading the binaries and putting them in your $GOPATH

Leave a Reply