35 ms·
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 i
by snug 5y ago
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
- pinkrobotics 5y agowow, thank you! I did not know this. It will be very useful!
- leephillips 5y agoI’ve used !$ forever to substitute the last word from the previous command, but I never knew about this.
- naikrovek 5y agook 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.
- snug 5y agoI press and hold escape first then period
- naikrovek 5y agoESC 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.
- snug 5y agoAhh 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
- lolive 5y agoI 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.
- snug 5y agoThis is something that comes with oh-my-zsh, love that feature!
- alex_smart 5y agoAlt + . 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.
- snug 5y agoDoesn't seem to work on mac :/
- alex_smart 5y agoI 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-shortcut-for-moving-the-cli/686/ https://lorenzo.mile.si/macos-iterm2-use-linux-keyboard-shor...
- snug 5y agoThanks, 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!