Linuxify your Mac
Recently I got offered a MacBook Pro by my company. Little did I know that how unfriendly macOS's UX really are until I daily-drive it. So here is some lifesaving hacks such that a long time Linux user like me can use the macOS.
Remap keysโ
The existence of ^
(Ctrl in Mac), โฅ
(Option in Mac) and โ
(Command in Mac) breaks my flow immediately.
In order to keep my muscle memory, here is the key remapping if you are used to Linux(specifically Gnome)/Windows.
For Apple Keyboard
- Ctrl
โ
-> Command - Option
โฅ
-> Control - Command
โ
-> Option
For Windows Keyboard
- Ctrl
โ
-> Command - Command
โ
-> Control
Use Commander One and remap keyโ
Mac's Finder is so bad that it is beyond saving. Just use Commander One. It provides a free version that has enough feature to make my life easier. It is good to configure the following as well.
- Backspace for parent folder
- Command + X -> Cut
Alt-Tabโ
Mac does not have the corresponding feature of Alt
+ Tab
. You are supposed to use Command
+ Tab
then Command
+ `.
You can install the following application to achieve the same thing.
The alt-tab that switches between windows but not application.
https://alt-tab-macos.netlify.app/
Configure the hotkey to be Option
+ Tab
. If you are using a Windows keyboard, it is going to be Alt
+ Tab
.
Swift Quitโ
Mac distinguish betweens document type application and normal application. Therefore clicking the x
button does different things for
different application.
The following application helps you regain your sanity. Quit the application after you have pressed the red button no matter whether that is an application or document. https://github.com/onebadidea/swiftquit
Rectangleโ
The windows snapping for Mac is very anti-ergonomic.
You should install Rectangle
to make it reasonable.
Windows Manager that supports Window-style keyboard snapping.
https://rectangleapp.com/
Set the following hotkeys
Super
+ Up : MaximizeSuper
+ Down: RestoreSuper
+ Left: Left HalfSuper
+ Right: Right HalfSuper
+Shift
+ Left: Move to the left monitorSuper
+Shift
+ Right: Move to the right monitor.
Stats.Appโ
The best Mac System monitor app is Stats
.
You can download it from here.
Home-End Behaviourโ
The Home
and End
button does not have consistent behaviour on Mac. The only way to make it easier
to use is to set up the KeyBinding yourself. Here is the configuration that I am using.
https://cobus.io/posts/2017-02-09/osx-home-end-keys/#:~:text=This%20remapping%20does%20the%20following,start%20and%20end%20of%20document
Create a file /Users/gordonlau/Library/KeyBindings/DefaultKeyBinding.dict
. Put in the following content.
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
"^\UF729" = moveToBeginningOfDocument:; // ctrl-home
"^\UF72B" = moveToEndOfDocument:; // ctrl-end
"^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
"^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end
}
https://jeffmikels.org/posts/how-to-fix-home-and-end-keys-in-the-mac-terminal/
This link also fixes the home-end behaviour for the terminal application. Please note that \0
is Escape and it is an capital O but not zero.
- home :: \033OH
- end :: \033OF
Mission Control hotkey for Snappingโ
Change the hot key for Snapping to Ctrl
+ Up for showing mission control and Ctrl
+ Down for showing only the application.
Next Tab/Previous Tabโ
The next tab/previous tab behaviour is not consistent across different applications.
In Windows, they are Ctrl
+ Page Up
and Ctrl
+ Page Down
.
But in Mac, they are different for different applications.
The only true consistent hotkey are
Command
+Shift
+[
: previous tabCommand
+Shift
+]
: next tab
Terminal's Ctrl + C and Command + C issueโ
In terminal, Ctrl+C
is sending SIGINT
๏ผโ+C
is copying files. Since I have already mapped โ
to Ctrl
on a Windows Keyboard. I cannot use
Ctrl+C
to send SIGINT
.
- Installing
iTerm
, setCopy
andPaste
to^+Shift+C
and^+Shift+P
respectively. And add^+C
to sendSigINT
,^+D
to sendSigTERM
and^+z
to sendSigTSTP
. UseiTerm
to replace the built-in terminal of Mac. - In vscode, set vscode to sendSequence when
^+C
,^+D
and^+z
to send signal while terminal is in focus.
[
...
{
"key": "shift+cmd+c",
"command": "-workbench.action.terminal.openNativeConsole",
"when": "!terminalFocus"
},
{
"key": "shift+cmd+c",
"command": "workbench.action.terminal.copySelection",
"when": "terminalTextSelectedInFocused || terminalFocus && terminalHasBeenCreated && terminalTextSelected || terminalFocus && terminalProcessSupported && terminalTextSelected || terminalFocus && terminalTextSelected && terminalTextSelectedInFocused || terminalHasBeenCreated && terminalTextSelected && terminalTextSelectedInFocused || terminalProcessSupported && terminalTextSelected && terminalTextSelectedInFocused"
},
{
"key": "cmd+c",
"command": "workbench.action.terminal.sendSequence",
"args":{
"text": "\u0003"
},
"when": "terminalFocus"
},
{
"key": "cmd+d",
"command": "workbench.action.terminal.sendSequence",
"args":{
"text": "\u0004"
},
"when": "terminalFocus"
},
{
"key": "cmd+z",
"command": "workbench.action.terminal.sendSequence",
"args":{
"text": "\u001a"
},
"when": "terminalFocus"
}
...
]
- If you are using IntelliJ, simply disable the terminal and open
iTerm
whenever you want to use Terminal.iTerm
is superior than the small terminal anyway. - Basically you need to configure each terminal in every application to do the same. Therefore I use mostly
iTerm
on Mac due to this issue.