10.09.2014

Bash (Unix shell)

Bash is a Unix shell written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell (sh).Released in 1989,  it has been distributed widely as the shell for the GNU operating system and as a default shell on Linux and Mac OS X. It has been ported to Microsoft Windows and distributed with Cygwin and MinGW, to DOS by the DJGPP project, to Novell NetWare and to Android via various terminal emulation applications. In the late 1990s, Bash was a minor player among multiple commonly used shells, unlike presently where Bash has overwhelming favor.

Bash is a command processor that typically runs in a text window, where the user types commands that cause actions. Bash can also read commands from a file, called a script. Like all Unix shells, it supports filename wildcarding, piping, here documents, command substitution, variables and control structures for condition-testing and iteration. The keywords, syntax and other basic features of the language were all copied from sh. Other features, e.g., history, were copied from csh and ksh. Bash is a POSIX shell, but with a number of extensions.

The name itself is an acronym, a pun, and a description. As an acronym, it stands for Bourne-again shell, referring to its objective as a free replacement for the Bourne shell. As a pun, it expressed that objective in a phrase that sounds similar to born again, a term for spiritual rebirth. The name is also descriptive of what it did, bashing together the features of sh, csh, and ksh

Keyboard shortcuts

The following shortcuts work when using default (Emacs) key bindings. Vi-bindings can be enabled by running set -o vi.


Note: For shortcuts involving Alt, you may be able to use Esc instead.


Note: Sometimes, you must use Esc instead of Alt, because the Alt shortcut conflicts with another shortcut. For example, in Trisquel 5.0 (a distribution of Linux), pressing Alt+f does not move the cursor forward one word, but activates "File" in the menu of the terminal window.


See also: Readline

Tab ↹ : Autocompletes from the cursor position.

Ctrl+a : Moves the cursor to the line start (equivalent to the key Home).

Ctrl+b : Moves the cursor back one character (equivalent to the key ←).

Ctrl+c : Sends the signal SIGINT to the current task, which aborts and closes it.

Ctrl+d

Sends an EOF marker, which (unless disabled by an option) closes the current shell (equivalent to the command exit). (Only if there is no text on the current line)

If there is text on the current line, deletes the current character (then equivalent to the key Delete).

Ctrl+e : (end) moves the cursor to the line end (equivalent to the key End).

Ctrl+f : Moves the cursor forward one character (equivalent to the key →).

Ctrl+g : Abort the research and restore the original line.

Ctrl+h : Deletes the previous character (same as backspace).

Ctrl+i : Equivalent to the tab key.

Ctrl+j : Equivalent to the enter key.

Ctrl+k : Clears the line content after the cursor and copies it into the clipboard.

Ctrl+l : Clears the screen content (equivalent to the command clear).

Ctrl+n : (next) recalls the next command (equivalent to the key ↓).

Ctrl+o : Executes the found command from history, and fetch the next line relative to the current line from the history for editing.

Ctrl+p : (previous) recalls the prior command (equivalent to the key ↑).

Ctrl+r : (research) recalls the last command including the specified character(s). A second Ctrl+r recalls the next anterior command that corresponds to the research

Ctrl+s : Go back to the next more recent command of the research (beware to not execute it from a terminal because this command also launches its XOFF). If you changed that XOFF setting, use Ctrl+q to return.

Ctrl+t : Transpose the previous two characters.

Ctrl+u : Clears the line content before the cursor and copies it into the clipboard.

Ctrl+v : If the next input is also a control sequence, type it literally (e. g. * Ctrl+v Ctrl+h types "^H", a literal backspace.)

Ctrl+w : Clears the word before the cursor and copies it into the clipboard.

Ctrl+x Ctrl+e : Edits the current line in the $EDITOR program, or vi if undefined.

Ctrl+x Ctrl+r : Read in the contents of the inputrc file, and incorporate any bindings or variable assignments found there.

Ctrl+x Ctrl+u : Incremental undo, separately remembered for each line.

Ctrl+x Ctrl+v : Display version information about the current instance of Bash.

Ctrl+x Ctrl+x : Alternates the cursor with its old position. (C-x, because x has a crossing shape).

Ctrl+y : (yank) adds the clipboard content from the cursor position.

Ctrl+z : Sends the signal SIGTSTP to the current task, which suspends it. To execute it in background one can enter bg. To bring it back from background or suspension fg ['process name or job id'] (foreground) can be issued.

Ctrl+_ : Incremental undo, separately remembered for each line.

Alt+b : (backward) moves the cursor backward one word.

Alt+c : Capitalizes the character under the cursor and moves to the end of the word.

Alt+d : Cuts the word after the cursor.

Alt+f : (forward) moves the cursor forward one word.

Alt+l : Lowers the case of every character from the cursor's position to the end of the current word.

Alt+r : Cancels the changes and puts back the line as it was in the history.

Alt+u : Capitalizes every character from the cursor's position to the end of the current word.

Alt+. : Insert the last argument to the previous command (the last word of the previous history entry).a

0 comments:

Post a Comment