Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

> !$ - I use this dozens of times a day. It repeats the last argument of the last command.

Press ESC then full stop instead. Less key presses.



sort by: page size:

> Then you can press escape [..]

Don't forget Ctrl-[ instead of Esc. I find that more quick, especially with Ctrl in place of CapsLk. :)


This drives me bonkers, especially if I've been using the shell a lot recently and I'm used to pressing ctrl+r to repeat a previously used command.

Probably the most useful commands that aren't mentioned in most tutorials are:

ctrl-[ can be used in place of ESC

. repeats the last edit


>by far the most useful shortcut for me is Ctrl-r

I rarely ever use Ctrl-r since I usually know the starting part of the command I want. So, I type those starting characters and use up/down arrow keys, courtesy these lines in `~/.inputrc`

    "\e[A": history-search-backward
    "\e[B": history-search-forward

> Control+Shift+C just doesn’t cut it for me on Linux.

Use middle click.


> No way to pause a command and view the man.

^A, ^K, m, a, n, space, ^Y, enter. Upon exit, ^Y.

> No way to set a command aside.

^A, ^K. Grab it again with ^Y.

(Yes, these are all readline shortcuts. If you think they’re a bit long, bind them to something shorter in your inputrc.)


>Many of my commands start identically but continue and end differently. Here C-r (or ^R if you prefer) is the most convenient.

Not sure if I understood this correctly. You can use up/down arrow multiple times, just like Ctrl-r/s - so it is a huge improvement for me.


I often use Ctrl-C to abandon a command I'm typing and get a new prompt.

ctrl-[

(a habit I picked up on DEC and Wyse and etc... terminals where the key labeled ESC was in different locations)


I think command+t and command+w are usually my go to methods. I don't have to move my hands from my keyboard.

I don't use !!, or !$, because I prefer to see what command is being executed before I press enter. For the same reason, I will never use !word. But that's not a problem, because as others have noted bash makes it easy to not have to fall back to these.

Alt-. will generally add the prior last argument into the current command, and repeated presses will cycle through previous commands.

Ctrl-r will dynamically update to show you the prior command matched as you start typing afterwards, so you can confirm it's correct.

Both are essential if you want to reuse prior commands but either can't trust that you were the last person using the shell, or don't want a typo to ruin your day, and possibly many other people's day as well. That is, if you're a sysadmin using the automatic variants, I don't want you anywhere near systems I rely on, I want you far away. Perhaps working for a competitor.


> Cmd+esc takes you to the previous up from cmd+tab

I've always used cmd+~ for that


>You can use ctrl-x ctrl-e in most terminals.

Shells, not terminals.


> If you've typed or pasted a long command and decide you need to edit it before running, ctrl-x-e opens it in an editor

Jeez, this is great!


>I press command-option esc to Force Quit an app

why? command-Tab (switch between and show running apps) and command-Q (force quit)

also you can use command w to close a window if really really want to go that route


Not a word about command editing.

Learn keyboard shortcuts to edit the current command line and you'll save years of your life.

ESC-. (dot) will get the last argument of the last command. This one alone will save you months.

CTRL-R will search backwards. This other will save more months.


Shift + Shift + Command + ESC + Shift + 1 + ~ + Shift + Esc + CTRL + Command + Shift + F1 + \x00 + F3 + ~

Phew! Finally back to my terminal


<control>-j + <control>-w for me (on Linux). That solves the major annoyance of this, which is not having a keyboard command for closing it.

Lol that makes sense, never thought of commenting out the command but I guess I do something similar. If i realize i dont want a command yet I enter it with a trailing `\`, then `CTRL+C` to get back to an empty prompt.
next

Legal | privacy