blog/content/2014-06-21_readline.rst
2022-10-16 23:02:04 -04:00

43 lines
2.1 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Readline
########
:date: 2014-06-21 04:01
:author: tyrel
:category: Tech
:tags: readline, linux, cli
:slug: readline
:status: published
A lot of times when I stop at someones computer and help them in the terminal, I use a Readline command and people say “How the heck did you do that?”
Let me first backup and explain what Readline is. From the GNU Readline Documentation “The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in.” By default, Readline is set up in Emacs mode, no you dont have to have an extra four fingers to use Readline, most of the commands are simple.
Here are a couple of the commands I use daily:
Movement
~~~~~~~~
- To move to the beginning of a line, you press **C-a**
- To move to the end of a line you press **C-e**
Killing and Yanking
~~~~~~~~~~~~~~~~~~~
- To cut the rest of the line from where your cursor is, to the end, you press **C-k**
- To delete one word you press **C-w**
- To paste either of the two previous back you can press **C-y**
Miscellaneous
~~~~~~~~~~~~~
- To clear the screen and get to a fresh start, you can press **C-l**
- To end your session you can send a **C-d** (This will send an end of file character)
- To search for a command you typed recently, press **C-r** and start typing, it will search backwards. **C-r** again will search for an earlier match.
- The inverse of **C-r ** is **C-s**, they function the same.
Finally, dont forget about **C-c**. While not specifically Readline, its very useful because it sends the SIGINT signal to the program, which if just on the command line, will not execute the line you have type, and give you a new line with nothing on it. A nice clean start.
To find out a lot more, read the documentation at `the Readline Commands Docs <http://www.gnu.org/software/bash/manual/html_node/Bindable-Readline-Commands.html>`__ I even learned some things while writing this up, apparently pressing **C-x $** will list off all the possible usernames. Good to know, and good to always keep learning.