Changing MacOS keybindings for Home/End keys to behave the same as Windows

Sometimes muscle memory is hard to unlearn. I can’t get used to the Home and End keys on a Mac jumping to the top and end of a file instead of start and end of a line. Yes, I know Cmd-left and Cmd-right do the same thing on a Mac, but pressing Home and having it jump to the top of a file is too much for me to handle when in the middle of editing something in an IDE like Eclipse.

To remap the Home and End keys to behave the same as on Windows, make a dir here:

mkdir ~/Library/KeyBindings

and create a file called DefaultKeyBindings.dict containing this content:

{
"\UF729" = "moveToBeginningOfLine:";
"\UF72B" = "moveToEndOfLine:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
}

Logoff and log back on again, and the Home and End keys should now work the same as on Windows. (source here)

If this still doesn’t work in Eclipse, it maybe because Line Start and Line End and explicitly mapped to Cmd-left and Cmd-right – these can be changed in Preferences under Keys:

Delete the existing mappings for Home and End and change to the Home and End keys:

Moving from msql client to mysqlsh

I posted a while back about running mysql in a Docker container on an Apple Silicon MacBook. It’s been a while since I’ve run mysql locally, and it seems the mysqlsh client is now preferred over the previous mysql client.

With mysqlsh, after connecting, to issue a ‘use’ command to select a db, use ‘\use dbname’

Once a db is selected, to issue other mysql commands enter the sql mode with ‘\sql’ command.

MacOS curl error: “zsh: no matches found”

I’ve seen this error before with MacOS’s zsh and I can never remember what the issue is:

> curl https://localhost:8080/example?email=test
zsh: no matches found: https://localhost:8080/example?email=test

You can get this error with multiple different commands for the same reason. The ‘?’ in the param to curl is interpreted as a substitution wildcard character. To avoid the issue, either escape the ? as \? or just wrap the whole url in double quotes.

Samsung Picture by Picture (PBP) screen resolution support with MacOS

I recently just got a 4k Samsung monitor that supports Picture in Picture (PiP) and Picture By Picture (PBP) modes from multiple input sources, which is awesome because I tinker with a bunch of stuff on different machines at the same time. My 2015 MacBook Pro has no problem recognizing the unusual PBP resolution of half the width of a 4k display, but for my older 2008 Mac Pro that I use as my daily driver while I’m at my desk it stretches the resolution vertically which is not good. From this Samsung post here here it mentions the side by side resolution for 2 BPB inputs is 1920 x 2160. That’s definitely not a normal resolution, but the Nvidia web driver in my Mac Pro with a Nvidia 750ti doesn’t offer that resolution:

How to configure PIP/PBP size?

The way round this is to use SwitchResX to define a custom resolution. I’m running Mac OS X 10.11 on this Mac Pro, so I also need to follow these steps to temporarily disable SIP protection first in order to save the configs for the custom resolution.

To set a custom resolution of 1920 x 2160 – here I selected ‘Use simplified settings’ (which disabled a number of settings) and changed only the height/width and left all the other settings as default:

By default this set the vertical sync as 60hz and after rebooting the Display prefs didn’t pick this one up as a valid option. Dropping it to 30hz works through.

I also set a lower res to be more easily readable:

Save from menu bar, then it prompts to reboot to become active. After rebooting, open the Display settings in System Prefs, and now under the Scaled options for the monitor in PBP mode you’ll see the new custom resolutions available:

1920×2160 is almost too tiny to be readable for my eyes, but 1600×1800 is a comfortable resolution.