Readline (Italiano)

From ArchWiki
Revision as of 09:29, 12 October 2011 by Maveloth (talk | contribs) (created page with content from Bash (Italiano))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary end

Readline is a library by the GNU Project, used by Bash and other CLI-interface programs to edit and interact with the command line. Before reading this page please refer to the library home page as only subtle configuration will be introduced here.

Command-line editing

By default Readline uses Emacs style shortcuts for interacting with command line. However, vi style editing interface is also supported. If you are a vi or vim user, you may want to put the following line to your Template:Filename to enable vi-like keybindings:

set -o vi

You may find either vi or emacs cheat sheets useful.


Usually, pressing the up arrow key will cause the last command to be shown regardless of what has been typed so far. However, users may find it more practical to list only past commands that match the current input.

For example, if the user has typed the following commands:

In this situation, when typing Template:Codeline and pressing the up arrow key, current input will be replaced with Template:Codeline, the last performed command. Had history search been enabled, only past commands beginning with Template:Codeline (the current input) would've been shown, in this case Template:Codeline.

You can enable this mode by adding the lines below to Template:Filename or Template:Filename:


If you chose to add the aforementioned two lines to Template:Filename, it is recommended that you also add the following line at the beginning of this file to avoid strange things like this:

$include /etc/inputrc

Alternatively, one can use reverse-search-history (incremental search) by pressing Template:Keypress+Template:Keypress, which does not search based on previous input but instead jumps backwards in the history buffer as commands are typed in a search term. Pressing Template:Keypress+Template:Keypress again during this mode will display the previous line in the buffer that matches the current search term, while pressing Template:Keypress+Template:Keypress (abort) will cancel the search and restore the current input line. So in order to search through all previous Template:Codeline commands, press Template:Keypress+Template:Keypress, type 'mount' and keep pressing Template:Keypress+Template:Keypress until the desired line is found.

The forward equivalent to this mode is called forward-search-history and is bound to Template:Keypress+Template:Keypress by default. Beware that most terminals override Template:Keypress+Template:Keypress to suspend execution until Template:Keypress+Template:Keypress is entered. (This is called XON/XOFF flow control). For activating forward-search-history, either disable flow control by issuing:

$ stty -ixon

or use a different key in Template:Filename. For example, to use Template:Keypress+Template:Keypress which is not bound by default:


Ricerca nella cronologia

Evitare i duplicati

Se si ripetono spesso diversi comandi, essi verranno aggiunti ogni volta alla propria cronologia. Per evitarlo, aggiungere questo al proprio Template:Filename:

export HISTCONTROL=ignoredups

Evitare gli spazi

Per impedire che vengano considerati nella cronologia i comandi vuoti aggiungere questa linea al file Template:Filename:

export HISTCONTROL=ignorespace

Se nel file è già presente

export HISTCONTROL=ignoredups

Sostituirlo con

export HISTCONTROL=ignoreboth


Readline supporta anche l'assegnazione di combinazioni di tasti a delle macro. Per esempio, eseguire questo comando in Bash:

bind '"\ew":"\C-e # macro"'

o aggiungere la parte contenuta tra apici al file Template:Filename:

"\ew":"\C-e # macro"

Adesso scriviamo una linea e premiamo Template:Keypress+Template:Keypress. Readline si comporterà come se avessimo premuto Template:Keypress+Template:Keypress (spostamento a fine riga) ed aggiungerà 'Template:Codeline'.

Usare ogni possibile combinazione di tasti per una macro tramite readline, può essere molto utile per automatizzare le opreazioni effettuate spesso. Ad esempio questa macro fa si che la combinazione Template:Keypress+Template:Keypress+Template:Keypress aggiunga "| less" alla linea e la esegua (Template:Keypress+Template:Keypress equivale a Template:Keypress):

"\e\C-l":"\C-e | less\C-m"

Il comando successivo inserisce ad inizio riga la stringa 'yes |' quando viene premuta la combinazione Template:Keypress+Template:Keypress+Template:Keypress, utile per confermare ogni domanda di tipo yes/no dal terminale:

"\e\C-y":"\C-ayes | \C-m"

Questo esempio incapsula la linea digitata all'interno di Template:Codeline, se vinene premuta la combinazione Template:Keypress+Template:Keypress:

"\es":"\C-a su -c '\C-e'\C-m"

Come ultimo esempio, per avviare facilmente un comando in background con Template:Keypress+Template:Keypress+Template:Keypress, redirigendo ogni tipo di output:

"\e\C-b":"\C-e > /dev/null 2>&1 &\C-m"

Tips and Tricks

Disabilitare la visualizzazione delle combinazioni control

A causa di un aggiornamento di Template:Package Official, il terminale ora visualizza Template:Codeline dopo aver premuto Template:Keypress+Template:Keypress. Per gli utenti che vogliono disabilitare questa visualizzazione, basterà semplicemente aggiungere la seguente linea al file Template:Filename:

set echo-control-characters off