News for hackers. Stuff that matters.
Re:Linux Terminal Tools [pdf] by snug on Tuesday May 04, 2021 @04:18PM (#27042384)
The secret that I never see brought up on any of the linux command line tools is "esc + ." - It's by far one of the most valuable tricks I've learned, it will insert the last thing from the last command

ls /foo/bar/this_is_the_file.txt

cat "esc + ."

which expands to

cat /foo/bar/this_is_the_file.txt

Re:Linux Terminal Tools [pdf] by lolive on Wednesday May 05, 2021 @12:11AM (#27046102)
I agree, and some days ago, in another thread, I got +10 on my comment detailing this shortcut.

Another no-brainer imho is editing you /etc/inputrc or your $HOME/.inputrc and bind keys (usually PgUp and PgDn) to history-search-backward and history-search-forward.

From there you can navigate your history like with the arrows, but it will only consider lines that starts with the string that is currently on the command line.

It is a MUST.

Re:Linux Terminal Tools [pdf] by snug on Wednesday May 05, 2021 @12:57AM (#27046355)
This is something that comes with oh-my-zsh, love that feature!
Re:Linux Terminal Tools [pdf] by alex_smart on Wednesday May 05, 2021 @01:49AM (#27046638)
Alt + . does the same thing as well, with the added advantage that you can keep pressing Alt and then hit "." several times to go through all the "last arguments" in your history one by one.
Re:Linux Terminal Tools [pdf] by snug on Wednesday May 05, 2021 @02:56AM (#27046965)
Doesn't seem to work on mac :/
Re:Linux Terminal Tools [pdf] by alex_smart on Wednesday May 05, 2021 @03:03AM (#27047004)
I haven't used a mac in years, but I know for sure that I had found a workaround. I would go insane without "Alt+." on the shell, I use it very, very frequently.

Try this: https://lorenzo.mile.si/macos-iterm2-use-linux-keyboard-shor...

Re:Linux Terminal Tools [pdf] by snug on Wednesday May 05, 2021 @12:29PM (#27052049)
Thanks, i'm using iTerm2, which seems to have an experimental feature for repeat previous character escape sequence enabled by default, but doesn't really work that well, I suspect it's the touchbar escape key that doesn't play too nicely to the hold

edit: I'm dumb, that was for iTerm, I got it working!

Re:Linux Terminal Tools [pdf] by leephillips on Tuesday May 04, 2021 @04:44PM (#27042659)
I’ve used !$ forever to substitute the last word from the previous command, but I never knew about this.
Re:Linux Terminal Tools [pdf] by pinkrobotics on Tuesday May 04, 2021 @04:26PM (#27042472)
wow, thank you! I did not know this. It will be very useful!
Re:Linux Terminal Tools [pdf] by naikrovek on Tuesday May 04, 2021 @11:00PM (#27045703)
ok this is going to sound stupid, but I don't care. learning time, for me.

do you type the literal characters "esc + ." or do you press CTRL+[ then period, or do you push the escape key, then period, or do you push escape and period at the same time?

I'm not at a terminal to try any of this and find out for myself.

Re:Linux Terminal Tools [pdf] by snug on Tuesday May 04, 2021 @11:50PM (#27045975)
I press and hold escape first then period
Re:Linux Terminal Tools [pdf] by naikrovek on Wednesday May 05, 2021 @01:11PM (#27052654)
ESC isn't a control code like CTRL or SHIFT or ALT - so holding it while you press another key is weird, to me.

But pressing and releasing ESC and then pressing and releasing period works excellently. Thank you.

Re:Linux Terminal Tools [pdf] by snug on Wednesday May 05, 2021 @01:20PM (#27052775)
Ahh nice, yeah, that works, I always just assumed I needed to hit ESC first, but didn't know they didn't need to be held at the same time