5 ms·
Using readline is a great thing to know about too. My favourite little-known readline command is operate-and-get-next: https://www.gnu.org/software/bash/manua
by jordigh 9y ago
Using readline is a great thing to know about too.
My favourite little-known readline command is operate-and-get-next:
https://www.gnu.org/software/bash/manual/html_node/Miscellaneous-Commands.html https://www.gnu.org/software/bash/manual/html_node/Miscellan...
You can use it to search back in history with C-r and then execute that command with C-o and keep pressing C-o to execute the commands that followed that one in history. Very helpful for executing a whole block of history.
For some reason, this documentation is hard to find! It's not here, for example:
http://readline.kablamo.org/emacs.html http://readline.kablamo.org/emacs.html
I'm a bit saddened when readline replacements don't implement C-o. For example, the Python REPLs don't have it.
- coaxial 9y agoctrl-o doesn't seem to do anything for me. ctrl-r, find a command, press ctrl-o -> inserts ^o in the command and exits of ctrl-r. Running bash 4.4.12(1) on Linux.
- lillesvin 9y agoI've overridden ctrl-r in my local Bash to search with fzf[0] and I'm using my history so much more now. Didn't know about ctrl-o though, it sounds great! I hope that my ctrl-r override doesn't somehow break it. [0]: https://github.com/junegunn/fzf https://github.com/junegunn/fzf E: Fixed link.
- CaptSpify 9y agoThat link is a 404 for me?
- tokenizerrr 9y agoIt had a trailing >, https://github.com/junegunn/fzf https://github.com/junegunn/fzf
- hinkley 9y agoI have since gotten out of the habit, but when I was just starting out I gave myself CTS one Christmas doing a giant refactor with just vi to remove a disasterous idiom from the codebase that was O(n^2). I knew a quite a few commands but I didn’t know the block indentation commands and that was about a third of my typing over that week. After that, part of my regular “I’m tired or there’s nothing to work on” routine included reading the accelerator key documentation for my editor of choice. I found all sorts of good stuff and it really made me faster for quite some time. Now I do more analysis work and the accelerators that help there are less numerous. Fast code nav being a critical one. But some of these tools make it pretty hard to find all their features, which is a shame.
- pdkl95 9y agoAnother obscure readline feature is that ~/.inputrc accepts key sequences bound to arbitrary (quoted) macros, including macros that contain more key sequences. # a basic macro that types "foo" bound to META+"f" "\ef": "foo" The cool part is that bash recursively checks the macro output for more key sequences. For example, I use these standard bindings: # <META>-k "\ek": shell-kill-word # <CONTROL>-y "\C-y": yank # <SHIFT>-RIGHT "\e[c": shell-forward-word # <SHIFT>-LEFT "\e[d": shell-backward-word ...which are used by these macros that use s-LEFT and s-RIGHT to move the current command-line argument one position left or right: # <SUPER>-LEFT "\e[D": "\e[d\ek\e[d^Y" # <SUPER>-RIGHT "\e[C": "\e[d\ek\e[c^Y" # ^ ^ ^ ^ # | | | > yank # | | > shell-forward-word # | > shell-kill-word # > shell-backward-word (the actual key sequences depend on the terminal. Check with C-v <KEY>)