How to Navigate Linux Command Line Using Keybinding (Linux Ctrl Command Examples)
2015-02-10 21:54
477 查看
How to Navigate Linux Command Line Using Keybinding (Linux Ctrl Command Examples)
by AARON TABOR on MAY12, 2014
Tweet
A keybinding is simply the mapping of a specific key combination to an action.
Keybindings that we are all familiar with outside of the command line environment are things like:
Control-c: copies selected text
Control-v: pastes copied text
In this tutorial, we’ll take a look at some of the default keybindings provided in the command line environment (and also where to look if you forget one).
There are many keybindings available by default when working in the Linux command line to make navigation and editing much easier. They are powered by a tool called Readline.
Here are few I often use (If you are familiar with the Emacs editor, you will likely see similarities):
Movement Keybindings
The following keybindings are used for movements:Keybinding | Description |
---|---|
Control-a | Position cursor at the start of the line |
Control-e | Position the cursor after the last character of the line |
Control-f | Move the cursor forward by one character (same behaviour as the arrow key) |
Control-b | Move the cursor backwards by one character (same behaviour as the arrow key) |
Deletion Keybindings
The following keybindings are used for deletions:Keybinding | Description |
---|---|
Control-k | Delete all text after (and including) cursor |
Control-u | Delete all text before (not including) cursor |
Control-w | Delete immediate WORD before cursor (a WORD is a sequence of any consecutive non-whitespace characters) |
Control-h | Delete char before cursor (think backspace) |
Control-d | When text exist => delete char under cursor (think delete). When no text => exit shell |
History Keybindings
The following keybindings are used for history:Keybinding | Description |
---|---|
Control-p | Cycle to previous command |
Control-n | Cycle to next command |
Control-r | Reverse index search (allows you to type part of a command. searches in reverse order through command history for a matching command) |
Misc Keybindings
The following are few misc keybindings:Keybinding | Description |
---|---|
Control-l | Clear display (similar to ‘clear’ command) |
Control-j | Execute current command (same as Enter/Return) |
Control-c | Cancel current command, return empty prompt |
Control-/ | Redo the last undone edit |
Control-? | Undo the last edit |
To see a full list currently bound and available keybindings and functions use the ‘bind’ command (this is a good quick reference when you forget one):
$ bind -p
You’ll see output that looks something like this:
"\C-g": abort "\C-x\C-g": abort "\e\C-g": abort "\C-j": accept-line …
The format here is:
key combination: binding
Please note that you’ll use the same format to define your own custom keybindings.
Remember that you can use grep to find the bindings you are interested in.
For example, to see only the binding that use the Control key:
$ bind -p | grep '\\C'
Note: In the above command, I’ve got to escape the backslash (\) character in the grep string.
Tweet
> Add your comment
If you enjoyed this article, you might also like..
{ 11 comments… read them below or add
one }
相关文章推荐
- How To Download a RPM Package Using yum Command Without Installing On Linux
- How to install Database using commandline prompt
- 使用VLC命令行做流化:Streaming HowTo/Command Line Examples
- HowTo: Use grep Command In Linux / UNIX [ Examples ]
- How to Cheat at Windows System Administration Using Command Line Scripts
- How to find PID of process listening on a port in Linux? netstat and lsof command examples
- C++ How to avoid the enter key when using cin and getline
- How to change Red Hat Linux to boot to command line mode from Gnome
- How to view or edit pdf/image metadata from command line on Linux
- How To Uninstall Software Using The Ubuntu Command Line
- How to install oracle by Command Line Interface(CLI) in silent mode on Linux
- How to access Dropbox from the command line in Linux
- How to identify video formats from command line on Linux
- Linux - How to remove the new line at the end of file when using vim
- 15 Examples To Master Linux Command Line History
- How To Use Ip Command In Linux with Examples
- How do I import a new Java CA cert without using the keytool command line utility?
- How to Mount and Unmount Filesystem / Partition in Linux (Mount/Umount Command Examples)
- How to install IIS 7.5 on Windows 7 using the Command Line
- How to download files from the Linux command line