Hacker News new | past | comments | ask | show | jobs | submit login

TIL Alt-clicking in the Terminal prompt lets me move the cursor to that position. How had I not discovered this over many years?



Not having this has been my #1 Terminal frustration for years... and it's been there this whole time?!?!

This type of thing has actually happened to me several times in the past year or so, where I'd be frustrated an obviously good feature doesn't exist, I'd Google it to see if other people complain about the same thing... only to find it exists after all.

There needs to be a word for this...


It's been one of my #1 terminal frustrations, too!!! But instead of relying on GUIs and the mouse, I started to use terminal tools and wrote a plugin for tmux that helped me. https://github.com/schasse/tmux-jump Maybe it's useful for you.


There's an initialism for it, used by the people who know about the feature to describe the people who didn't: RTFM.


Very funny.

If I read the manual for everything I've ever used, I'm not sure I'd have time to actually accomplish anything in the end.

Sure, let me spend a day reading through the lists of keyboard/mouse shortcuts for every piece of software I use just to see if there's anything useful in there? No thanks...

Good UX would pop up a balloon informing me of the feature after the first time I held down my left-arrow key for more than, say, keypresses.


CLIs are like that. On the bright side, things rarely change. So the stuff you read in the manual 30 years ago still likely works. I prefer it over relearning GUIs with every update.

Of course, you might as well disregard the manual and discover things on your own as you need them. Nevertheless, it helps to go at this with a mindset of "this feature surely already exists" lest you're compelled to develop a worse version of the feature yourself.


[flagged]


While technically true, I tend to forget what I read after some time, especially tips and tricks that did not seem that useful when I first read them. So RTFM is not the silver bullet unless you somehow have a system that reminds you to re-read every manual every x months.


Which terminal? In Linux, Alt+Left Click is the "move window around" idiom, while Alt+Right Click is "resize window with the mouse".


How can you know that this is a common idiom? Is there an (prob. GNU)-document for these things? Two reasons I am asking: 1) I feel terrible reading this, since my last post was preaching for XCFE for this exact functionality. 2) It would be awesome to have these things bundled and discover many things which are yet not discovered by me.


The major Linux desktops have had this sort of thing for like 15 years. It’s usually only discovered by people who obsessively tweak their settings, though.


Dont think that its a standart of some kind, but KDE does the same thing


I'd imagine it was Terminal on MacOS from the capitalisation (and that does what he says, just checked.)


Yes. That would be Mac iTerm/Terminal, should have mentioned.


Do people usually use "Alt" to describe the Option key on Macs? I was really confused for a second trying to find it on my Macbook


Yes.

Anyone that hasn't been exclusively using macOS for their entire digital life, or at least years, anyway.

'Command' (resp. 'Windows', resp. 'Super') is a different story. You can't say 'Super' with a straight face without also marking yourself out as someone who borders on saying 'GNU with Linux', or 'I run Arch'.

(For what it's worth, I do run Arch. ;))

IIRC Option is dually labelled as Alt on some Apple keyboards anyway.


> You can't say 'Super' with a straight face without also marking yourself out as someone who borders on saying 'GNU with Linux', or 'I run Arch'.

Since basically nobody knows the historical difference these days, I just call it the Meta key to avoid the above situation. When non-techy people ask me what the hell I mean, I just explain that's the technical term for the key and that I use it so both Mac and Windows people understand me. I've even heard one of them start using the term themselves, presumably to appear smarter in front of their boss.


While it's not wrong to refer to the Super key as "Meta", I don't like calling it that, because in some contexts (like emacs), "Meta" means the Alt key.


I use a USB mechanical keyboard with my Mac, Ubuntu at home, so I tend to think of command and option as super and alt.


I want this badly on gnome-terminal. If anyone has this type if thing on a linux plz. advise.


I agree, but also can recommend a few good shortcuts...

<c-a> = go to beginning of line

<c-e> = go to end of line

!! = repeat last command

<esc> b = move "back" one word (also <c-b> and <c-left>)

<esc> f = move "forward" one word (also <c-f> and <c-right>)

Many others exist. See `man bash` under READLINE.


By the way, recently discovered you can get some of these shortcuts in all input boxes by activating “emacs shortcuts” inside of gnome-tweaks! Was one of the final blockers for getting me from Mac to Linux


You can also use the more standard Home/End/Ctrl+Left/Ctrl+Right to do all of the above. Much easier to remember and works in any other editor also.


!cmd = repeat last usage of that command

!!enter which is 3 buttons where as up-arrow enter is the same thing.


!! is more useful than you think. It's substitute last command here, not just up-arrow enter.

See sudo !!.


Yes! I use c-u to clear the line all the time.


And <c-w> clears the previous word :) Also <c-y> pastes the line/word back in (so you cant think of it like cut-copy).


Shift+click works for me.


I tried this in vim but didn't work. TIL "set mouse=a" enables moving cursor by mouse click in vim.


To add what was an essential follow-up for me when I discovered this: Once you’ve enabled mouse=a, use the alt key to select text in vim for your system clipboard, rather than vim’s visual mode.


I don't understand this part. How do you select using Alt?

Typically with mouse enabled, you can select text with the mouse, but this doesn't go to the X clipboard. While with mouse disabled, text selected with the mouse goes to the X clipboard.


What I had meant was that when using vim configured with mouse=a, selecting with the mouse while holding down the Alt key would disable the terminal emulator's mouse reporting and allow the selection to be copied to the system clipboard.

But actually this depends entirely on the terminal emulator. The Alt/Option key works with the default preferences for iTerm2 on MacOS, but with GNOME terminal I reproduced the same behavior using Shift instead.


Found another interesting problem. mouse=a works great on my Ubuntu laptop; however, it has no impact when connected to Linux servers via Putty - when I click somewhere in the vim window, the cursor doesn't jump to that spot.


You might need something beyond mouse=a to get Putty to report the mouse through to vim—maybe this option? https://superuser.com/questions/513014/moving-cursor-in-putt...


wow, this is very handy.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: