This page has been robot translated, sorry for typos if any. Original content here.

Shell shortcuts

Shell shortcuts

Short introduction

This post will talk about some keyboard shortcuts that can make life easier for administrators working in the console. All of them work in bash'e. I additionally checked the keyboard shortcuts on tsisk (Cisco IOS Software, s72033_rp Software (s72033_rp-ADVIPSERVICESK9_WAN-M), Version 12.2 (33) SXH4), csh and zsh. Considered in other entries I will not particularly repeat. Combinations are grouped by the used function key.

This text will be especially useful for people who like to use the Home, End, and Delete keys (which “don't work” in the tsisk console).

Combinations

First, some keyboard shortcuts with ctrl.

  • Ctrl + a - go to the beginning of the line ( cisco , csh , zsh )
  • Ctrl + b - go back 1 character ( cisco , csh , zsh )
  • Ctrl + c - sends the program SIGINT. Usually interrupts the current job ( csh , zsh )
  • Ctrl + d - deletes the character under the cursor (analogue to delete) ( cisco , csh , zsh )
  • Ctrl + e - go to the end of the line ( cisco , csh , zsh )
  • Ctrl + f - go forward 1 character ( cisco , csh , zsh )
  • Ctrl + k - deletes everything, to the end of the line (EOL, not on the screen!) ( Cisco , csh , zsh )
  • Ctrl + l - clears the screen. An analogue of the clear command. ( csh , zsh )
  • Ctrl + r - search by history. Repeating a search (paging search results). That is, incremental search. ( zsh )
  • Ctrl + j - stops the search and allows you to edit the found command. If the search was not performed, then it is similar to pressing return. (in zsh it executes the command)
  • Ctrl + t - changes the character under the cursor to the previous one. Or, if you want, pulls the previous character to the end of the line. ( cisco , csh , zsh )
  • Ctrl + u - deletes all characters to the left of the cursor to the beginning of the line. ( cisco , in csh , zsh deletes the entire line)
  • Ctrl + w - Deletes the characters to the left of the cursor to the beginning of the word. ( cisco , csh , zsh )
  • Ctrl + xx - goes from the current position of the course to the beginning of the line and vice versa. On tsiska works similarly ctrl + u. ( csh )
  • Ctrl + x @ - shows possible additions to the host name (names are taken from / etc / hosts)
  • Ctrl + z - suspend the current task ( csh , zsh )
  • Ctrl + x; Ctrl + e - opens $ EDITOR to change the entered line. After saving the changes, the command is sent for execution. If the variable is not set, then the system text editor opens (for Linux it is often nano)

Now a little about combinations with viola.

  • Alt + < - go to the first command in the command history ( zsh )
  • Alt +> - go to the last command in history
  • Alt +? - shows a list of possible additions to the command (similar to tab-tab) (in csh , zsh the analogue of which string)
  • Alt + * - inserts all possible additions to the command line
  • Alt + / - tries to supplement the file name (similar to tab)
  • Alt +. - inserts the last argument of the previous command (analog! $, Just don’t have to: p to check)
  • Alt + b - moves the cursor left by 1 word ( cisco , csh , zsh )
  • Alt + c - makes the letter under the cursor big, and the rest, to the end of the word, small. ( cisco , csh , zsh )
  • Alt + d - deletes characters from the current cursor position to the end of the word. ( cisco , csh , zsh )
  • Alt + f - moves the cursor one word forward ( cisco , csh , zsh )
  • Alt + l - makes all letters from the current cursor position to the end of the word small ( cisco , csh , zsh )
  • Alt + t - swaps the words under the cursor and the previous ( zsh )
  • Alt + u - translates letters from the current cursor position to the end of the word in upper case ( cisco , csh , zsh )
  • Alt + back-space - removes characters from the current cursor position to the beginning of the word ( cisco , csh , zsh )

In the next paragraph, for brevity, I will write "2T" to indicate a double tab.

  • 2T is a complement to the team. If you click on an empty line, it displays a list of all available commands
  • (string) 2T - will display a list of possible additions
  • (dir) 2T - will show subfolders of the dir folder
  • * 2T - will show subfolders excluding hidden ones (whose names begin with a dot)
  • ~ 2T - displays all users from / etc / passwd. By adding the username, you can go to his home directory. For example ? ~ Oxpa /
  • $ 2T - displays a list of add-ons for system variables
  • @ 2T - Adds hostnames to / etc / hosts
  • = 2T - listing of the current directory, similar to ls.

Little conclusion

Since in my work I most often use bash and cisco's shell, I simply signed combinations that, I know, work for other shells as well. Csh features , zsh is probably no less than Bashovskys, I just worked less with them.

The above list will not show correctly without explanation: all these hot keys in bash can be reassigned. There are actions that are not assigned to hotkeys by default. Such “tricks” are described in the bash’s manual, which I recommend reading to everyone who is interested.