Here are some useful things for computer usage which might be too small in themselves for a separate blog post.
Table of contents
- Browser profiles
- Browser start page
- Temporary pasteboard in browser
- Hotkeys to instantly open and hide apps
- macOS Dock spacers
- CLI aliases
- Alt-drag to resize windows
- Hammerspoon hotkey to toggle preset window sizes
- Hammerspoon menu to access specific settings quickly
- Other apps
Browser profiles
Chrome and Safari have browser profiles and Firefox has multi-account containers. With the profiles, you can separate cookies, local storage, browser history, bookmarks, themes and extensions to separate accounts from each other.
- Use Chrome with multiple profiles
- Use profiles in Safari on Mac
- Firefox Multi-Account Containers
- Firefox does have profiles, but switching is not seamless: Profile Manager - Create, remove or switch Firefox profiles
Browser start page
When using multiple profiles, managing bookmarks becomes a bit of a hassle. I’ve mostly started to use a general start page that has most commonly used links, hotkeys to specific sites, and link search. The actual bookmarks between the profiles differ, but there is no need to sync the bookmarks between each other when the shareable links between profiles are added to the startpage.
Temporary pasteboard in browser
Opening a plain contenteditable
in a tab in a browser can act as a temporary place to paste things. Also works for images. You can bookmark this Scratchpad to use it.
data:text/html, <html contenteditable>
Hotkeys to instantly open and hide apps
Originally I used Apptivate, but it hasn’t been updated in a while, so I’ve made a Hammerspoon implementation. A hotkey or a chord of keystrokes is used to instantly open or hide (if active) application. It becomes second nature and one doesn’t need to even think about cmd-tab, finding specific icons or windows to activate the app they need.
function launchOrHideBundle(bundleName)
local currentlyActive = hs.application.frontmostApplication()
local bundle = currentlyActive:bundleID()
if (bundle == bundleName) then
currentlyActive:hide()
else
hs.application.launchOrFocusByBundleID(bundleName)
end
end
function launchOrHide(appname)
local currentlyActive = hs.application.frontmostApplication()
local name = currentlyActive:name()
if (name == appname) then
currentlyActive:hide()
else
hs.application.launchOrFocus(appname)
local c = hs.application.get(appname)
c:activate(true)
end
end
hotkeys = hs.hotkey.modal.new()
hotkeys:bind({ "ctrl" }, "c", function()
launchOrHideBundle("com.google.Chrome")
end)
hotkeys:bind({ "ctrl" }, "f", function()
launchOrHideBundle("com.apple.finder")
end)
hotkeys:bind({ "ctrl" }, "t", function()
launchOrHideBundle("com.googlecode.iterm2")
end)
hotkeys:bind({ "ctrl" }, "v", function()
launchOrHideBundle("com.microsoft.VSCode")
end)
hotkeys:bind({ "ctrl" }, "§", function()
launchOrHide("Writer")
end)
hotkeys:bind({ "ctrl" }, "l", function()
launchOrHide("VSCodium")
end)
hotkeys:enter()
macOS Dock spacers
Not every app needs a hotkey, but is useful to have in the Dock all the time, which can lead to a messy and unorganised look. macOS supports spacers in the Dock, but there is no GUI to add them. Chris Pennington has a nice blog post how to add them.
CLI aliases
Making a short alias even for a short & simple command can make the terminal experience much nicer. Some examples that I have:
alias "c"="code"
alias "co"="codium"
alias "cdd"="cd ~/Dev"
alias "cdh"="cd ~/.hammerspoon"
alias "l"="lazygit"
alias "ll"="ls -1alh"
alias "oo"="Open ."
alias "tree"="tree -N -I node_modules"
alias "zreload"="source ~/.zshrc"
alias "cleardns"="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder"
Alt-drag to resize windows
Feature which allows moving and resizing windows just by holding down alt (or other keys) and using left/right click for actions instead of needing to select the tiny window borders.
- macOS:
- SkyRocket Hammerspoon Spoon
- Easy Move-resize
- Windows:
- Linux: usually supported out of the box. Check your distros settings.
Hammerspoon hotkey to toggle preset window sizes
hs.hotkey.bind({ "alt" }, "s", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local first = { w = 1300, h = 1700 }
local second = { w = 1600, h = 1900 }
if (f.w == first.w and f.h == first.h) then
setWindowSize(second.w, second.h)
else
setWindowSize(first.w, first.h)
end
end)
If you want to them to be conditional to the screen resolution, you can check the screen width for example:
hs.hotkey.bind({ "alt" }, "x", function()
local screenWidth = hs.screen.mainScreen():currentMode().w
local win = hs.window.focusedWindow()
local f = win:frame()
local first = {
w = screenWidth == 3840 and 1000 or 900,
h = screenWidth == 3840 and 1100 or 900
}
local second = {
w = screenWidth == 3840 and 700 or 700,
h = screenWidth == 3840 and 800 or 800
}
if (f.w == first.w and f.h == first.h) then
setWindowSize(second.w, first.h)
else
setWindowSize(first.w, first.h)
end
end)
Hammerspoon menu to access specific settings quickly
If you’re using multiple displays at different places and sound setups in meeting rooms, it’s useful to be able to instantly access a specific setting in system preferences. They can be opened with a CLI command and Hammerspoon can run those. Example script below and it’s a continuation from a previous Hammerspoon app launcher menu post.
local choices = {
{
text = "System Settings",
subText = "Preferences", appName = "System Settings",
image = hs.image.imageFromAppBundle("com.apple.systempreferences")
},
{ text = "System settings: sound",
shellCommand = "open -b com.apple.systempreferences /System/Library/PreferencePanes/Sound.prefPane",
image = hs.image.imageFromAppBundle("com.apple.systempreferences")
},
{ text = "System settings: network",
shellCommand = "open -b com.apple.systempreferences /System/Library/PreferencePanes/Network.prefPane",
image = hs.image.imageFromAppBundle("com.apple.systempreferences")
},
{ text = "System settings: trackpad",
shellCommand = "open -b com.apple.systempreferences /System/Library/PreferencePanes/Trackpad.prefPane",
image = hs.image.imageFromAppBundle("com.apple.systempreferences")
},
{ text = "System settings: display",
shellCommand = "open -b com.apple.systempreferences /System/Library/PreferencePanes/Displays.prefPane",
image = hs.image.imageFromAppBundle("com.apple.systempreferences")
},
{ text = "System settings: Bluetooth",
shellCommand = "open -b com.apple.systempreferences /System/Library/PreferencePanes/Bluetooth.prefPane",
image = hs.image.imageFromAppBundle("com.apple.systempreferences")
},
{ text = "System settings: Keyboard",
shellCommand = "open -b com.apple.systempreferences /System/Library/PreferencePanes/Keyboard.prefPane",
image = hs.image.imageFromAppBundle("com.apple.systempreferences")
},
{ text = "System settings: Mouse",
shellCommand = "open -b com.apple.systempreferences /System/Library/PreferencePanes/Mouse.prefPane",
image = hs.image.imageFromAppBundle("com.apple.systempreferences")
},
}
local customChooser = hs.chooser.new(function(choice)
if choice ~= nil then
if choice.shellCommand ~= nil then
hs.execute(choice.shellCommand)
end
chooser:hide()
end
end)
local currentScreen = hs.mouse.getCurrentScreen()
local fullFrame = currentScreen and currentScreen:fullFrame()
local width = (500 / fullFrame.w) * 100
customChooser:width(width)
customChooser:rows(18)
customChooser:placeholderText("Choose app"):searchSubText(true):choices(choices)
Other apps
- Darktable: image processing app and Lightroom alternative
- DeskPad: virtual monitor that is useful for screensharing
- Espanso: text expansion
- FSNotes: good note taking app that saves files as plain text files, has folder, tag & Git support
- IINA: mpv with nice GUI for macOS
- Karabiner elements: keyboard customization
- Keka: create and extract archive files, inlcuding 7z
- MonitorControl: adjust non-Apple monitor display brightness & contrast via hotkeys & GUI
- Monodraw: ASCII diagramming tool
- NameChanger: bulk file & folder renamer
- OBS: streaming and recording software. Has a virtual webcam feature and is useful if you need to present something. See previous demoing mobile apps -post
- Phoenix Slides: folder based image browser
- Radio Silence: block network traffic for specific apps. Not as configurable as Little Snitch or LULU, but easy to use & cheap
- Stats: show system usage statistics in the menubar
- Tiny Player: simple audio player
- CLI
- nnn: file browser & manager, which has completely replaced usage of
cd
for me. The wiki is quite extensive and remember to configure cd-on-quit. - lazygit terminal Git client, with really good UI. Has made using Git actually comfortable and fast for me.
- nnn: file browser & manager, which has completely replaced usage of
Configuring macOS
Finder
- Settings -> Advanced -> Show all filename extensions
- Settings -> Advanced -> When performing a search: search the current folder
- Settings -> Sidebar -> Add user and external disks to the sidebar
- View -> Show path bar
- View -> Show status bar
Settings
- Network -> Firewall -> enable
- Keyboard -> Key repeat rate to fast
- Keyboard -> Delay until repeat to short
- Keyboard -> Keyboard shortcuts -> Function keys -> Use F1, F2, etc. keys as standard function keys
- Keyboard -> Keyboard shortcuts -> Keyboard -> Update the Move focus to next window -hotkey since it’s hard to access on ISO nordic layout by default
- Keyboard -> Keyboard shortcuts -> Mission control -> Mission control to
opt+tab
Keyboard -> Keyboard shortcuts -> Mission control -> Application windows toshift+opt+tab
- Mouse -> Tracking speed to slowest and adjust mouse DPI. This seems to have none or at least very little mouse acceleration
Other
Remove delay from Dock autohide
defaults write com.apple.dock "autohide-delay" -float "0" && killall Dock
Reset to default:
defaults delete com.apple.dock "autohide-delay" && killall Dock
defaults -currentHost write -globalDomain NSStatusItemSpacing -int 6
defaults -currentHost write -globalDomain NSStatusItemSelectionPadding -int 12
Reset back to defaults:
defaults -currentHost delete -globalDomain NSStatusItemSelectionPadding
defaults -currentHost delete -globalDomain NSStatusItemSpacing