40 ms·
Quick tip for developers who use OS X
OSX Terminal: hold option and click a position in the current line to move your cursor to that position. #yearslost
- mahadazad 13y agothanks for the tip
- jhwhite 13y agoI did not know this. Thanks! Very helpful tip.
- gargarplex 13y agovia http://apple.stackexchange.com/questions/5435/got-any-tips-or-tricks-for-terminal-in-mac-os-x http://apple.stackexchange.com/questions/5435/got-any-tips-o...
- pinaceae 13y agothanks for posting the source, a lot of these tweets and posts about #yearslost don't reference it.
- archagon 13y agoGreat link, I spent a good while digging through there when I first found it. My favorite is using mdfind to leverage Spotlight for file search. Results come up instantly.
- _djo_ 13y agoWorks in iTerm too.
- caiob 13y agoThe problem here is the "click" part of it.
- blktiger 13y agoEvery once in a while it's much faster to just reach for the mouse than to use keyboard shortcuts.
- mikeroher 13y agoTwo more tips: * Ctrl-a to go to beginning of line * Ctrl-e to go to end of line
- koenigdavidmj 13y agoA lot of the Emacs shortcuts work in OS X (most of the system) as well as on Linux (bash and other users of readline).
- mikeroher 13y agoI use Vim and was unaware that this shortcut existed. Are there any other Emacs shortcuts which are useful in OSX?
- 65a 13y agoCtrl-K kill to end of line, so Ctrl-A Ctrl-K will clear a given field
- Fishkins 13y agoAnd you can Ctrl-Y to paste the line you killed. This is a separate copy/paste buffer from the normal Cmd-C one, which can be nice.
- coliveira 13y agoIf you do "set -o vi" you can also use vi shortcuts, such as ESC-j,k to go up/down the history, 0 to go to the beginning of the line, etc.
- pyre 13y agoYou cannot use 'set -o vi' to turn Cocoa text fields into vi-mode.
- deleted 13y ago[deleted]
- k-mcgrady 13y agoMost useful thing I've seen all day - thanks!
- niyazpk 13y agoWorks even when you are ssh-ed into a remote machine! Nice.
- penguindev 13y agoyep. I tried it myself thinking it wouldn't. wow.
- simonhamp 13y agoYou, sir, are a genius!
- Fishrock123 13y ago... Why didn't I know this before? Thanks for sharing!
- jackmaney 13y agoNice!
- grillermo 13y agoWorks on iTerm too!
- pfortuny 13y agoWell, if you do not want to use the mouse, you can always: Ctrl-e: go to the end of the line Ctrl-r: search backwards (input the text) and you go to the point where the search begins.
- rynop 13y agoNother related tip: command + click on a file in iTerm opens it up. Test it out by doing ls -al then cmd+click on file name.
- tunnuz 13y agoType "set -o vi" on your bash, and you can edit your commands with the vi shortcuts.
- yogsototh 13y agoOK, so for vim users with zsh: bindkey -v Now be happy, hit <ESC> and, use ^ and $ but also f<letter> t<letter> and also ,;. You can copy/paste with dd, Y, etc...
- slunk 13y agoFyi, bash also has vi-mode (set -o vi).
- pyre 13y agobash uses GNU readline, while ZSH has it's own readline. IIRC the Emacs-/Vi-modes in bash are support from readline. (this is also why you configure some of these things via .inputrc for Bash rather than .bashrc).
- coliveira 13y agoset -o vi does the trick for vim. Most vi commands work, but when you type <ESC>v this will open vi to edit your command line, in case you feel any command is missing.
- GrinningFool 13y agoI've b een using vi-mode in the shell for a while,but haven't been able to get the <ESC>v behavior you described. Did you have to do anything to make that behave?
- coliveira 13y agoI haven't done anything, my version works under Mac OS X.
- ghotli 13y agoOsx terminal uses almost all of the emacs movement keys by default. Ctrl-a and ctrl-e are useful but I find the meta movement keys to be the most helpful. (usually alt or ESC) Meta-f jump forward a word Meta-b jump backwards a word
- pyre 13y agoI'm not sure what you're suggesting here. It's up to the process running in Terminal.app to support the key sequences sent to it. I doubt that M-f would work if your shell (bash, zsh, etc) were in Vi-mode rather than the default of Emacs-mode.
- te_chris 13y agoIt's not emacs, it's GNU Readline (or likely some BSD readline given apple and the GPL) http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html. The shortcuts also work in every text field in the OS.
- pyre 13y agoIIRC, someone mentioned to me once that bash doesn't link against libreadline, but uses libreadline (the source is directly in the Bash repo), so it's possible that it's using GNU readline, while Apple's libreadline is a BSD flavour.
- SeanLuke 13y agoTerminal may be using some kind of Readline, I dunno. But text objects in other OS X applications use emacs keybindings because NeXTSTEP has had them since time immemorial. Like 1990 or so. Doesn't have anything to do with GNU Readline so far as I know.
- petercooper 13y agoA new one for me I accidentally found the other day.. If you use Spotlight to find something and then want to see the file in Finder, Cmd+click the item in the Spotlight dropdown. Edited from Cmd+shift+click due to note in child comment :-)
- yuxt 13y agoisn't it just Cmd+click ?
- petercooper 13y agoOh hey, so it is, even better! :)
- samelawrence 13y agoyes.
- NatW 13y agoIn Mavricks (only one I can be sure of) when you hover over spotlight results and hold Cmd, you get a (quite nice) file preview/info.
- deleted 13y ago[deleted]
- panzi 13y agoUnder Konsole/Yakuake (KDE) its: Contextmenu -> Open Link
- pygy_ 13y agoYou can also use Cmd + Return.
- bluthru 13y agoCmd + R is universally "Reveal in Finder".
- deleted 13y ago
- natch 13y agoUseful when copy/pasting things to share with other people in email and such: $ pbpaste | pbcopy takes the current contents of the copy/paste buffer and removes color/font/background color rich formatting and puts just plain text back into the paste buffer. And of course pbcopy and pbpaste are also very useful on their own.
- Janteh 13y agoYou can also use shift-option-cmd-v to directly paste without markup :)
- natch 13y agoI can never remember which combination that is, but thanks.
- jmreid 13y agoYou can override any key combination using the Keyboard preferences. Just make a new shortcut under the All Applications group named exactly the same as the one you want to replace. http://i.imgur.com/JqBncTy.png http://i.imgur.com/JqBncTy.png I've also had to add an entry for "Paste as Quotation" because that's Mail's default use of Command-V.
- revscat 13y agoBe warned, though, that these do not work inside of a tmux session without special steps being taken. I believe that they work in screen, but tmux requires some additional work.
- bwilliams 13y agoYou have to install "reattach-to-user-namespace" which you can do with homebrew. Then you need to add the following to .tmux.conf set-option -g default-command "reattach-to-user-namespace -l zsh" There's a good writeup on what and why here, https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/master/README.md https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/blob/...
- deleted 13y ago[deleted]
- e28eta 13y agoI like checking the box in preferences to use Option as Meta, and then option + left/right will jump a word at a time, and option + backspace will delete the previous word, just like in most Cocoa apps.
- josho 13y agoAlso useful is Apple's support doc listing of keyboard shortcuts. http://support.apple.com/kb/HT1343 http://support.apple.com/kb/HT1343
- drcongo 13y agoLovely, thanks. Also, is it common knowledge that CMD+click on a URL opens that URL in your default browser? Useful for the "Running on http://127.0.0.1:5000/" http://127.0.0.1:5000/" messages.
- benwoodward 13y agoNice tip, thanks. However, it only works with double-click for me.
- rsynnott 13y agoThat's in iTerm, I think. In Terminal.app, it's CMD+double-click.
- macinjosh 13y agoTip: Real hackers don't use a mouse. /s
- pyre 13y ago... so do they prefer a track ball or TrackPoint (or some sort of Minority Report gestures-based system)? /s
- mariusmg 13y agoNo, they just use the keyboard. And use a mouse emulator (move pointer with the keyboard) on those instances where there's no kb shortcuts.
- Refefer 13y agoPerhaps it's simply personal preference, but I do find that limiting my mouse usage has resulted in real, tangible gains. I don't know how feasible that is in GUI-first operating systems like OS X, though.
- lunixbochs 13y agoCheck out Alfred 2, Shortcat, Slate (https://github.com/lunixbochs/reslate https://github.com/lunixbochs/reslate). You don't need the mouse as much as you might think.
- natch 13y agoI wish there was a way to make the mouse cursor stand out more when (and only when) it's over the terminal. Maybe it's because I use a dark terminal background, I can hardly ever see the thing. There's a system wide setting to make the cursor huge, but I don't want a huge cursor everywhere. And there's a terminal preference to make the insertion cursor different, but that's a different cursor, not the mouse cursor. When do I want to see the mouse cursor? It's useful for things like highlighting a git hash or a few lines of text for copy/paste.
- mikeswiss 13y agoin windows theres something where you can press controll and it will shoot circles out from your mouse which is pretty useful, not sure if there is anything like that in osx
- fordh 13y agoThere are a few options for cursor highlighting here: http://osxdaily.com/2011/07/12/3-ways-to-make-the-mac-os-x-cursor-more-visible-for-presentations/ http://osxdaily.com/2011/07/12/3-ways-to-make-the-mac-os-x-c...
- redeemedfadi 13y ago<Ctrl> X, <Ctrl> E to edit the current line in your default editor.
- SDMattG 13y agoThis is amazing. You have saved me countless seconds of frustration :-)
- kineticfocus 13y agoMaybe even more than that...lol... (Andy Hertzfeld & Steve Jobs Re: boot times) http://www.folklore.org/StoryView.py?story=Saving_Lives.txt http://www.folklore.org/StoryView.py?story=Saving_Lives.txt
- niuzeta 13y agoyearslostcounter++;
- deleted 13y ago[deleted]
- sazeod 13y agoOr you can use vim editing mode directly in bash using: set -o vi this makes most vim motions available at the command line after hitting "esc"
- thebouv 13y agoThe OP tip is nice to have built-in now. If I recall correctly, this was an option that had to be turned on in Terminal Preferences in earlier releases. Another fave of mine: Ctrl-w for deleting whole "words" at a time. Better than holding that delete key down. The default shell for OS X appears to be bash (my favorite shell as a Linux user as well). Just google for Bash shortcuts. Here's a place to start: http://teohm.github.io/blog/2012/01/04/shortcuts-to-move-faster-in-bash-command-line/ http://teohm.github.io/blog/2012/01/04/shortcuts-to-move-fas...
- andr 13y agomdfind to get Spotlight results in shell. Also, iTerm is a great Terminal replacement, if you haven't tried it.
- auvi 13y agomdfind is awesome!
- sgt 13y agoiTerm does not support OP's tip though.
- schnable 13y agoI wanted to like iTerm, but lack of restoring sessions (pwd, history) was a deal breaker.
- justinhj 13y agoUse mdfind in emacs as your locate command: (when (eq system-type 'darwin) (setq locate-command "mdfind"))
- deleted 13y ago[deleted]
- juanre 13y agoBash, running in your terminal, understands both the Emacs and the Vi commands. By default is Emacs, so you can C-a (control-a) for beginning of line, C-p to go back in command line history, or C-r to search it. I prefer the Vi mode, though. Add to your .bashrc set -o vi Then you can press escape to go from input mode to normal mode; there k will take you to the previous line in command line history, j to the next line, ^ and $ to the beginning and end of the line, /something will search something back. Editing is really fast; move by words with w (forward) and b (backward), do cw to replace a word, r to replace a letter, i to go back to input. It will remember the last editing command, just as Vi, and repeat it when you press . in normal mode.
- adventureloop 13y agoI started using vi mode recently. The only thing that I really miss are ci and di commands.
- graywh 13y agoci and di aren't commands. c and d are operators and the i is part of the motion--specifically, text objects.
- andrewtbham 13y agogreat tip. on my system i added it to .bash_profile.
- SDGT 13y agoC-a : beginning line, C-e end line, alt+f forward word (unless system shortcut for file menu), alt+b back word, C-k kill line, C-b back char, C-f forward char. At least in my current setup, C-w yank and C-y paste works as well. Immensely helpful. Sometimes at+left/right does forward/ back word depending on the terminal emu. Note most of these keystrokes are valid in nano as well.
- pavanky 13y agoMore: - C-u to kill (cut) from current location to beginning of the line - C-k to kill (cut) from current location to end of line - C-w to kill (cut) from current location to beginning of word - C-y to paste (copied / cut) lines - C-l to clear screen (I use the shit out of this) - Ctrl + shift + '-' (holding ctrl, shift, minus at the same time), for undo. That is it. EDIT: Damn it, I didn't realize I was saying a bunch of the same things as you did. EDIT2 Thanks oinksoft for clearing up C-u and C-w.
- FlyingAvatar 13y agoI've always preferred, option + left/right for fast moving with left/right for fine adjustment so I don't have to leave the keyboard.
- coherentpony 13y agoWait, people use the mouse when they're in the terminal?
- Angostura 13y agoThey do now.
- purephase 13y agoI have tried to use Terminal, but I just can't. The ability to highlight and automatically have the text in clipboard is such a crucial feature in my workflow that not having it even as an option is a deal breaker. Once I started with iTerm and built a config/flow around it, I can't go back. Thanks for the tip though! I didn't realize this worked in Terminal too. I'll keep it in mind the next time I'm forced to use it.
- drpre 13y agoCommand-shift-v pastes the current selection into Terminal (and anywhere else in OSX).
- actionscripted 13y agoSame here. Switched to iTerm for proper mouse support in Vim, and you need only click (no option key) to move your cursor in Vim if you have `mouse=a` in your vimrc. I used to be a die-hard Terminal.app user but with Mavericks it felt incredibly sluggish doing everything from opening to listing files to editing things and this is another reason I moved to iTerm. Be warned, though, that if you're using Vim with Solarized you and you're trapped in low color mode you want to be sure you're declared as a 256 color term and update your `vimrc` to remove the following for the colorscheme to work properly: Remove: * let g:solarized_termcolors = 256 * let g:solarized_termtrans = 1 * let g:solarized_contrast = "normal" * let g:solarized_visibility = "normal"
- sd8f9iu 13y agoI added mouse support to Terminal via MouseTerm: https://bitheap.org/mouseterm/ https://bitheap.org/mouseterm/. Works like a charm with Vim.
- andrethegiant 13y agoCheck out TotalTerminal. It's a plugin for Terminal that has that feature among others. http://totalterminal.binaryage.com http://totalterminal.binaryage.com
- beshrkayali 13y agoSucks that it doesn't work in iTerm2.
- eddieroger 13y agoYes it does - I just tried it. Worked like a dream.
- beshrkayali 13y agoDon't know why it's not working in mine then: http://d.pr/v/mgsi http://d.pr/v/mgsi
- jkbr 13y agoIt does for me. iTerm2, build 1.0.0.20140112
- jsilence 13y agoIt does in mine.
- sgt 13y agoDoesn't work in mine either (Build 1.0.0.20130319). So it appears that we just need to upgrade, as others report that it works in more recent versions.
- jimhart3000 13y agoFor some reason when I try this in iTerm2, it jumps to a different command in my history. No idea what's going on there...
- kshay 13y agoI saw this too... It looks like when you opt-click above the current line, it jumps back in your history by... the same number of lines as your cursor is above the current line? Sort of an unusual feature. Nevertheless, when I'm careful to actually click on the current line, it works as described.
- 13y ago
- emehrkay 13y agodrag + drop files to terminal to get its location. I often do "cd " + dragon drop folder to get to that folder in terminal
- MaxGabriel 13y agoThere's a free app called Go2Shell that adds a button to finder to open the current directory in Terminal/iTerm. Also works great in conjunction with "open ."
- sandipc 13y agoWow, so simple but so useful. Thanks!
- lunixbochs 13y agoYou can drag/drop many things onto an application icon in the dock to open them in a new window. This includes dragging a folder's proxy icon to the terminal app to open the current Finder window in a new terminal. The proxy icon is the little icon in the top middle of the window, to the left of the name.
- kps 13y agoI'm a bit late, but it's useful to know that while dragging, keystrokes are handled normally. Using the parent comment's operation as an example, you can start dragging a folder in the Finder, then Command-Tab to the terminal (or hover over the Dock icon and then hover over the proxy window), Command-` to a particular terminal window, or Command-N to open a new one, and then type "cd " before finally dropping the file. ("cd " is nicely left-handed for those using the right hand for the pointing device.)
- adventureloop 13y agoAnother really useful command is the open $ open filename.png $ open . $ open -e filename.txt $ open -a Pixen filename.png The first command will open the file with the default application. Open . will open the current directory in finder, which I find very helpful. The -e flag will open the file in textedit. The -a will open the file in the given application name.
- panzi 13y agoUnder Linux there is a similar command: xdg-open
- richardwhiuk 13y agoor gnome-open. On Windows the equivalent is start (e.g. start C:\ )
- Someone 13y agoI use start all the time, but also frequently curse at its stupid argument grammar and its interaction with auto-quoting on auto-completion. For example, type start C:\Doc Next, hit tab to get start "C:\Documents and Settings" Now, hit return, and watch a new command window open with title "C:\Documents and Settings". Reason? If the first argument is a quoted string, it is used as the title of the window being opened (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true http://www.microsoft.com/resources/documentation/windows/xp/..., http://stackoverflow.com/questions/154075/using-the-dos-start-command-with-parameters-passed-to-the-started-program http://stackoverflow.com/questions/154075/using-the-dos-star...) If you ever use start in batch scripts, pass a dummy first argument of ""
- krallja 13y agoYou can use `explorer`, which doesn't exhibit this behavior: explorer "C:\Documents and Settings" does what you'd expect.
- 13y ago
- ancarda 13y agoNobody seems to have posted this yet: python -m SimpleHTTPServer I'd recommend an alias like "serve". It basically puts the current directory online (binds to 0.0.0.0:8000).
- verandaguy 13y agoAm I wrong to have long dismissed this as little more than an easter egg, or, at best, a toy server to test basic webpage functionality?
- ramses0 13y agoYes. It's like a ghetto SCP for giving files to people on windows who don't have SCP. You can use it for basic web functionality, you can use it (carefully) as a mechanism for testing or serving test results. I wouldn't keep it running for days, but it's an amazingly useful tool.
- verandaguy 13y agoWhoa, never thought of it that way. The makeshift SCP is really a good idea!
- ancarda 13y agoI use it quite a lot to move files between my computers, stream content to my phone, test out web designs. I suppose it's like net cat, it's useful for some. I think "toy server" is fairly accurate, I can't see anyone using this in production but I can't see people installing nginx on their laptops either.
- kalleboo 13y ago> I can't see people installing nginx on their laptops either. OS X comes with apache preinstalled though
- thom 13y agoThe only problem it really solves is if you've got non-relative paths in your HTML/CSS. I've used this a couple of times in those situations.
- chavesn 13y agoYou can also CMD+click and drag (or double click as long as it's not a URL, which will open) to add to the text selection (like multiple cursors in Sublime Text 2). Also, Option+click and drag gives you column selection mode.
- fiveisprime 13y agoAnother useful tip is, in iTerm, map option+left and option+right to send escape sequence ^[b and ^[f respectively. :)
- lobster_johnson 13y agoOr you could set up your .inputrc to make arrow keys (eg., ctrl+arrow to jump between words) work properly. It also helps to learn the other Readline shortcuts (ctrl-A for home, etc.).
- SmileyKeith 13y agoI would lose years if I used the mouse in the terminal..
- zodvik 13y agoTo cut & paste files in Finder - use Cmd + C, then Cmd + Option + V.
- nimeshneema 13y agoThank you very much. Have been looking for this shortcut for eons. Made my Day :)
- apinstein 13y agoAnd if you use vim in the terminal, you can even use the mouse to select text... https://github.com/apinstein/dotfiles/blob/master/vimrc#L150-L164 https://github.com/apinstein/dotfiles/blob/master/vimrc#L150...
- jheriko 13y agoanother one, you can drag files and folders onto the terminal and it will paste the path in at the cursor position... very useful to cd to some path you have open in Finder
- guelo 13y agoAfter making the switch to OS X in the last couple years after living in Linux and Windows before that, I think it's objective to say that keyboard shortcuts in OS X are much worse in both ease of use and consistency across applications.
- dijit 13y agoI tend to find the opposite to be true. C-a is always "beginning of line" and Command-C is always Copy. and never the twain shall meet. (I've had issues in linux going from terminal to windows, in fact very recently I kept ^W'ing while in GUI mode)
- jeffcox 13y agoNot sure if I'm falling for sarcasm, or just an outlier for feeling the exact opposite...
- saurik 13y agoSame (and to be clear, this is from someone who only "switched" to OS X a few years ago because of the demands of my user community: and for the first year I hated it, as I liked neither the hardware nor OS X 10.5). So, to add some concrete-ness: what fundamentally makes OS X better at this is the way the command key is used; almost everything that has to do with the UI or the system is bound to the command key, which means that control and option are free for usage by my terminal. I thereby never run into any confusion using ctrl-c to copy something or alt-tab to switch between windows: command means nothing to my terminal, and control and option get bound to control and alt (not the default in Terminal, but its one checkbox to fix), passed to whatever actual application I'm running. On both Windows and Linux the control and alt keys tend to overlap in usage between graphical and console applications, meaning the graphical terminal I'm using invariably has some confusing overlap with the keyboard commands I might want to send to my console app. (Now, there are some unfortunate defaults in Terminal with relation to page up/down and home/end, but those are both easily fixed--a few minutes of setup before sitting down--and somewhat irrelevant as any one who even remotely cares about using a terminal should have installed iTerm2 forever ago.) (Ironically and relevantly, the reason Terminal has irritating defaults is specifically because Apple has actually been really good about having keyboard shortcuts be consistent across every application: they want option, page up, and home to do the exact same things in Terminal that it would do in any other app, even to the extent to which those behaviors are useless and counter-productive when you are actually just trying to use vim/emacs and bash/zsh like a normal person ;P.)
- lukabratos 13y agoIncrease or decrease volume by small increments: alt + shift + volume up / volume down or brightness up / brightness down. Also Alfred and Shortcat app.
- scelerat 13y agoThe first thing I do when setting up a new Mac is make the Caps Lock key into another Control key. System Preferences > Keyboard > Modifier Keys Saves lots of awkward pinky-bending.
- oneeyedpigeon 13y agoJust the fact that you can disable Caps Lock is a sanity-saver: thank you!
- lunixbochs 13y agoI go one step further and bind it to Hyper (ctrl+alt+cmd), and use hyper for tiling window management, like "snap window top left of screen grid", etc. https://github.com/lunixbochs/reslate https://github.com/lunixbochs/reslate
- deadfall 13y agoI did this on my Mac a few years back and do it on Windows machine at work. I also use Hotkeys to swap alt and ctl to match my Mac.
- 72deluxe 13y agoIs it me or do Mac Caps Lock keys require you to hold them down for close to a second for them to activate? There appears to be some kind of hardware timer in them to work...? I noticed this coming from Windows and Linux on other keyboards where tapping Caps Lock works but on Mac OSX with an Apple keyboard or on a Macbook you have to make a real deliberate effort to keep the key down longer than a nanosecond for it to register. Is it just me who has noticed this?
- chewxy 13y agoI noticed this on the lock screen. Often you'd have to tap multiple times on caps lock before it even turns on. I assume it's to prevent accidental caps locking, but it can be rather irritating
- dbtc 13y agoIt's not just you. I think it is to prevent accidentally toggling it when going for tab.
- michaelhoffman 13y agoIs there a way to do something similar in Linux? I use gnome-terminal but would think about switching to something with a feature this useful.
- virtualwhys 13y agoSame deal, Gnome terminal, alt-b, alt-f are the closest I've found.
- brbcoding 13y agoWhoa, it would seem that you can option click above the line and go back in history!
- weddpros 13y agosips -Z 1280 file.jpg to resize a photo easily...
- LeicaLatte 13y agoyou mean with a mouse? No.
- nailer 13y agoFYI this is 'Alt' on modern Mac keyboards.
- nocivus 13y agoNo one uses Terminal. iTerm ftw ;)
- Kiro 13y agoI use iTerm as well but besides from splitting panes and broadcasting I don't see the benefits. Why do you use it?
- rsynnott 13y agoTerminal.app wasn't very good back in the day; I think a lot of people ended up on it because of that and never went back. Also, CMD-click is far nicer for opening links than CMD-doubleclick :)
- btgeekboy 13y agoConversely, everyone I know (including myself) uses Terminal. I've never found a compelling reason to switch.
- davidedicillo 13y agoIf we'll ever meet, beer is on me. Thanks!
- xmodem 13y agoThis. changes. everything.
- 72deluxe 13y agosentences. seem. really. short. recently. but. I. don't. know. why. as. it. makes. the. text. impossible. to. read. and. also. makes. you. sound. like. you're. in. the. slow. readers. group.
- pilif 13y agoThis works if whatever is currently running in your terminal has support for the XTerm mouse escape sequences. Option-click is the shortcut to tell the terminal to forward the click to the application running in the terminal. That's usually your shell or some editor. I seem to faintly remember that at some point this was actually configurable and you could configure the terminal to forward non-option-clicks and only enable selection mode on option clicks. I didn't find this option in current iTerm or Terminal.app versions though - I might just be imagining this.
- tanvach 13y agoI can confirm that this works with VIM and nano
- albemuth 13y agoIf you'd rather not use the mouse, the fc command will open the last-executed command on vim (this is configurable, I suppose), saving and exiting the file executes the command!
- pketh 13y agoMind. Blown.
- lukasm 13y agoanother tip. Using mdfind you can do what find does but using Spotlight index
- adsrikanth 13y agoWhat do you mean by hold option?
- 72deluxe 13y agoConfusingly, the alt key that has had the word 'opt' put on it on some Apple keyboards and not on others... http://en.wikipedia.org/wiki/Option_key http://en.wikipedia.org/wiki/Option_key
- adriaanm 13y agoThe search clipboard: cmd-e is to cmd-g as cmd-c is to cmd-v.
- benwerd 13y agoThat was the least obvious thing ever, and you've just measurably improved my development experience. Thank you.
- roberthahn 13y agooo! As long as we're sharing our favourite terminal tips, here's mine: In your .bash_profile, add this line: alias imgsz='sips -g pixelWidth -g pixelHeight' sips stands for "scriptable image processing system"[1], and provides terminal users with a toolset for inspecting and manipulating images. The alias above is really useful for web developers who need a quick look at how big a given image is: $ imgsz logo.png /path/to/logo.png pixelWidth: 500 pixelHeight: 120 [1] https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sips.1.html https://developer.apple.com/library/mac/documentation/Darwin...
- aroman 13y agothank you!
- roberthahn 13y agohappy to help!
- raju 13y agoTwo more (for Bash) - Ctrl-x, Ctrl-e will pop open your EDITOR so you can edit the command. Saving and closing the editor brings the command back in your terminal and automatically executes it. fc will bring up your EDITOR with the last typed command. (You can use fc -l to see a list of commands)
- penguindev 13y agodamn.. thats the real #yearslost for me. I should have focused on learning that instead of the wordback/forward commands.
- critium 13y agoWhoa! I actually like this better than setting vi mode on terminal.
- escapologybb 13y agoGenius! That's going to save me so much time. :-) #yearslost
- thearn4 13y agoSimple, to-the-point, and very useful. Thanks!
- dsego 13y agoYou can type say "hello" and the terminal will greet you.
- IgorPartola 13y agoDoesn't work on iTerm2, which y'all should be using anyways. Besides being infinitely more configurable, and getting tabs right, it's also much faster when you are printing a bunch of text. No idea why OS X Terminal is so slow when it comes to this, but it's actually painful to `cat` a file of more than a thousand lines.
- ebzlo 13y agoI don't cat files too often in my workflow so I guess I don't have that pain point, but I find find iTerm2 has this minor annoying latency (kind of like typing on a wireless keyboard on low battery) that ultimately drove me away from it.
- IgorPartola 13y agoOdd. I have never experienced that problem. I don't cat files, but I list git diff output, view log files, etc. Even a large-ish git blame introduces a noticeable lag.
- bhaile 13y agoWorks for me on iTerm2.
- padmanabhan01 13y agoyears lost indeed..
- thucydides 13y agoMove cursor left or right word-by-word: alt + left arrow, alt + right arrow
- lloeki 13y agoGo to Keyboard Shortcuts in System Preferences and remap "Send reset" to cmd+ctrl+R or something, because it saves sanity when going back and forth between vi in a term and a browser.
- javajosh 13y agoOff-topic, but related: does anyone know a way to bind a key, and F-key for example, to a particular application in OSX? The behavior I'm looking for is almost achievable with Spaces - but it's basically when you hit the combo from anywhere, the target application comes to the foreground, or if it's not running, it launches. Command-Tab is fine and dandy, but I want more stability in my application switching. And if it doesn't exist, I may have to dust off XCode like I've been threatening to do for a while now.
- axit 13y agoSource: https://twitter.com/blackjack75/status/422036078540103681 https://twitter.com/blackjack75/status/422036078540103681 More tips linked in above tweet: https://apple.stackexchange.com/questions/5435/got-any-tips-or-tricks-for-terminal-in-mac-os-x https://apple.stackexchange.com/questions/5435/got-any-tips-...
- sandGorgon 13y agoSo I see a lot of comments in this thread about OSX has a much cleaner interpretation of Command-C vs Ctrl-C in Linux. Actually, the problem is that you should NOT be using ctrl-c to copy in linux. the global copy command in Linux obeys the CUA [1] standard. Copy is defined to be "Ctrl-Insert" and paste is defined as "Shift-Insert". This will work on all kinds of user interfaces on Linux - including the cmdline, the browser, etc. However this is an issue which I dont know is a bug or something (I'm on Ubuntu 12.04) - if you open "System Settings" in Ubuntu and copy text from there, I'm not able to paste it on the browser, but am able to paste it everywhere else using the command sequence described above. [1] http://en.wikipedia.org/wiki/IBM_Common_User_Access http://en.wikipedia.org/wiki/IBM_Common_User_Access
- whyme 13y agothank you; you just made my year!
- dustinbrownman 13y agoHoly guacamole! #lifechanged
- dustinbrownman 13y agoholy guacamole! #lifechanged
- desireco42 13y agoThank you :)
- scottyallen 13y agoThis appears to work in iTerm2 as well. Neat!
- khalidmbajwa 13y agoNothing will ever be the same again #HolyWow
- seanhandley 13y agoThis just made my day <3
- dnyce 13y agoWow. Talk about #yearslost!
- giuliano108 13y agocmd option mouse-drag: blockwise selection
- jbarham 13y ago20 years ago with Plan 9 you could have just clicked to move your cursor. Plus ça change...
- jaredsohn 13y agoOSX also features a lot of neat trackpad multitouch commands that some might not be aware of (my Windows trackpad doesn't understand multitouch.) Two fingers: up/down: scroll up/down, left/right: forward/back in some browsers (such as Chrome) Three fingers: up/down: show/hide a list of applications/desktops; left/right: switch desktops one at a time. Five fingers together/apart: show/hide desktop Before I discovered these, I was confused why I would occasionally see the forward/back arrow in the browser for a short period of time, not realizing that it showed because I happened to use a couple of fingers to move the mouse cursor.
- TheSoftwareGuy 13y agohttp://www.boastr.net/ http://www.boastr.net/ you can add tons of additional trackpad shortcuts too, as well as keyboard shortcuts.
- jlink 13y agoThanks !
- donskif 13y agoGreat tip, thanks. Another useful fyi that I haven't seen anybody else mention is the Bash framework bash-it [https://github.com/revans/bash-it/ https://github.com/revans/bash-it/]. It has tons of fantastic plugins, aliases and themes out of the box. I've only tried it on iTerm2, but as it only replaces your .bash_profile file it should work fine on Terminal.
- phronmophobic 13y agoI've found that maxing out the key repeat rate makes life better. System Preferences > Keyboard. Select the keyboard tab then move the Key Repeat slider all the way to the right.
- kozikow 13y agoI compiled my list of mac keyboard shortcuts and keyboard tricks: http://kozikow.wordpress.com/2013/10/31/going-mouseless-on-mac/ http://kozikow.wordpress.com/2013/10/31/going-mouseless-on-m... . Mac is the only non text based OS that you can control with 100% keyboard.
- mariusbutuc 13y agooops, not working in iTerm2...
- Phr34Ck 13y agohttp://apple.stackexchange.com/questions/5435/got-any-tips-or-tricks-for-terminal-in-mac-os-x/5502#5502 http://apple.stackexchange.com/questions/5435/got-any-tips-o...
- bingeboy 13y agoCome on kid! set -o vi == life saved
- makecheck 13y agoIn MacTerm, command+option+click will move the terminal cursor in the same way by simulating keys. It also moves “up” or “down”, for applications such as text editors that understand vertical arrows. There is even a preference setting that attempts to move the cursor automatically to wherever you drag and drop text with the mouse. (Note: I wrote MacTerm.)
- sweetp 13y agoholy shit.... thanks!
- leonvonblut 13y agohashtags on hacker news... please let me die. Nice tip!
- zytek 13y agoIf you use mouse to move around your Terminal, you're doing it wrong.
- mkeiser 13y agoI never understood the rationale of this behavior (not being able to just click anywhere to set the curser position). At least in not-yet-executed input.
- rajacombinator 13y ago#thankyousir
- mcella 13y agoGreat Tip! Regarding OSX Terminal, I'm an heavy user since Leopard but it's a shame that after upgrading to Mountain Lion (an now Mavericks) I discovered that they broke VIM vertical selection since control-shift does not generate a keycode anymore [1]. Anyone with the same problem? I tried iTerm recently and I don't like it! :-( [1] https://discussions.apple.com/thread/4694342?start=0&tstart=0 https://discussions.apple.com/thread/4694342?start=0&tstart=...
- etoulas 13y agoAs it wasn't mentioned yet: pushd / popd These two commands replace 'cd' and work with a directory stack of different paths. $ pushd tmp # cd to tmp and remember current path / /tmp / $ pwd /tmp $ cd /usr # normal cd to wherever you want... $ pwd /usr $ popd # pop the stck and get back to the previous path / $ pwd / Subsequent pushd will stack multiple paths. It's a built-in of bash and other shells. It works even with Windows' cmd.exe
- nightwolf 13y agoYou can also use "cd -" to go back to the previous path: $ cd / $ pwd / $ cd /tmp $ pwd /tmp $ cd - $ pwd / Not the same, of course, but still useful, I think.
- vincentwang 13y agoin .inputrc, I enable vi mode, and borrow some handful emacs keybindings(c-a beginning-of-line, c-e end-of-line, c-k kill-line etc) under vi insert mode, so I can get benefits from both worlds, just like what I did under vim :)
- WhiteFoxx 13y agooh my god thank you!
- laza 13y agocool, thanks
- eswat 13y agoIf you want to invoke a command in the menubar quickly - such as applying filters in Photoshop - hit Cmd + Shift + ?. Thill will bring up the Help Search menu and you can type the name of the menu item you want to invoke. Then just hit Enter and it’s done!