4 ms·
The bit about help as a subcommand and having to edit it out in a cumbersome way really hits home. I'm looking at you, otherwise-excellent wp-cli. :-)
by unfocussed_mike 5y ago
The bit about help as a subcommand and having to edit it out in a cumbersome way really hits home.
I'm looking at you, otherwise-excellent wp-cli. :-)
- AlexanderDhoore 5y agoYou need to discover either emacs or vim shortcuts for bash. I can't imagine living without `set -o vi`
- yjftsjthsd-h 5y agoAt least in bash, just run ^help^^ Which will rerun the previous command but substitute "help" with "" (nothing).
- unfocussed_mike 5y agoIt is in the nature of bash that you can go a decade without ever figuring something out only to have your life changed by a random comment on the internet. So thank you. That changes everything!
- yjftsjthsd-h 5y ago:D I have been on the receiving end enough times that I am very very happy to have passed it on this time.
- laurent92 5y agoIs there a shortcut to reuse the result of the last command? “which java => ll $(!!)”, but the “!!” reexecutes the last command, I’d like something which doesn’t.
- yjftsjthsd-h 5y agoI'm not personally aware of a way to do that. When I need to do that I do indeed just run $(!!)
- pcthrowaway 5y agoThis is amazing! I don't think I'll use it for help (up-arrow, ctrl+w is fewer keystrokes), but I can think of many other situations where I want to substitute one word of a very long command and didn't realize it could be this easy
- yesenadam 5y agoI think ^help^ does the same thing. The bash manual says ^string1^string2^ is equivalent to !!:s/string1/string2/ where / can be any delimiter, and the "final delimiter is optional if it is the last character of the event line." So, not so surprising that the third ^ is optional too. TIL: In either of these forms, if string1 is empty, it is set to the last string1, or, "if no previous history substitutions took place, the last string in a !?string[?] search." E.g. $ echo foofoo foofoo $ ^foo^ echo foo foo $ ^^bar echo bar bar
- unfocussed_mike 5y ago> is equivalent to > !!:s/string1/string2/ I didn't know about this syntax either. I thought I knew a bit of bash and it turns out I'm a novice after all this time. How fun.