brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Option-click moves the cursor on the line in Mac Terminal

Terminal
~/tips/tip-terminal-option-click-cursor

^ Option-click here

Places the cursor exactly where you click on a long command line.

Fixing a typo at the start of a long command usually means holding the Left arrow. In Terminal on the Mac you can point at the spot instead.

Hold Option and click on the character where you want the cursor. Terminal sends the arrow key presses for you, and the cursor walks there. Apple describes it as repositioning the insertion point with the Option key.

cp ~/Photos/holiday.jpg /Volumes/Bakcup/Photos/
                                   ^ Option-click here

It works on the command line of the shell, and also in full screen programs like vim and nano, as long as the program moves its cursor with arrow keys. It even works across wrapped lines of one long command.

iTerm2 has the same feature under the same modifier. In both apps a plain click and drag still selects text, so you don’t lose anything by learning this.

It goes wrong when the line is not where the terminal thinks it is. With a fancy two line prompt or a program that redraws the screen, the simulated arrow presses can land a row off or do nothing. Inside tmux or over a slow ssh link it also feels laggy, because it really is a burst of key presses. For those cases I find readline’s word jumps with Option as Meta are more predictable.

Further reading: Keyboard shortcuts in Terminal on Mac (Apple Support)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link