Readline bash

De Linuxmemo.

(Différences entre les versions)
Ligne 30 : Ligne 30 :
  Ctrl-D pour simuler une fin de fichier pour un programme qui lit les données dans l'entrée standard (par exemple pour terminer la session shell en cours ou pour terminer la composition d'un email avec mail).
  Ctrl-D pour simuler une fin de fichier pour un programme qui lit les données dans l'entrée standard (par exemple pour terminer la session shell en cours ou pour terminer la composition d'un email avec mail).
-
 
+
*Les arguments de commande
-
http://www.bigsmoke.us/readline/shortcuts
+
Alt-Ctrl-y pour coller le premier argument de la commande précédente
-
 
+
Alt-3 Alt-Ctrl-y pour coller le 3eme argument de la commande précédente (Alt-X permet de sélectionner un argument)
-
 
+
-
          Emacs keys
+
-
          Action
+
-
          Scope
+
-
          Direction/Place
+
-
       
+
-
     
+
-
 
+
-
     
+
-
       
+
-
          Moving around
+
-
          Ctrl-b
+
-
          Move the cursor
+
-
          one character
+
-
          ⇦ to the left
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-f
+
-
          Move the cursor
+
-
          one character
+
-
          ⇨ to the right
+
-
       
+
-
 
+
-
       
+
-
          Alt-b
+
-
          Move the cursor
+
-
          one word
+
-
          ⇦ to the left
+
-
       
+
-
 
+
-
       
+
-
          Alt-f
+
-
          Move the cursor
+
-
          one word
+
-
          ⇨ to the right
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-a
+
-
          Move the cursor
+
-
         
+
-
          ⇤ to the start of the line
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-e
+
-
          Move the cursor
+
-
         
+
-
          ⇥ to the end of the line
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-x-x
+
-
          Move the cursor
+
-
         
+
-
         
+
-
            ⇤⇥ to the start, and to the end again
+
-
 
+
-
         
+
-
       
+
-
     
+
-
 
+
-
     
+
-
       
+
-
         
+
-
          Cut, copy
+
-
and paste
+
-
         
+
-
          Backspace
+
-
          Delete
+
-
          the character
+
-
          ⇦ to the left of the cursor
+
-
       
+
-
 
+
-
       
+
-
         
+
-
            DEL
+
-
 
+
-
            Ctrl-d
+
-
         
+
-
          Delete
+
-
          the character
+
-
          underneath the cursor
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-u
+
-
          Delete
+
-
          everything
+
-
          ⇤ from the cursor back to the line start
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-k
+
-
          Delete
+
-
          everything
+
-
          ⇥ from the cursor to the end of the line
+
-
       
+
-
 
+
-
       
+
-
          Alt-d
+
-
          Delete
+
-
          word
+
-
          ⇨ untill before the next word boundary
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-w
+
-
          Delete
+
-
          word
+
-
          ⇦ untill after the previous word boundary
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-y
+
-
          Yank/Paste
+
-
          prev. killed text
+
-
          at the cursor position
+
-
       
+
-
 
+
-
       
+
-
          Alt-y
+
-
          Yank/Paste
+
-
          prev. prev. killed text
+
-
          at the cursor position
+
-
       
+
-
     
+
-
 
+
-
     
+
-
       
+
-
          History
+
-
          Ctrl-p
+
-
          Move in history
+
-
          one line
+
-
          ⇧ before this line
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-n
+
-
          Move in history
+
-
          one line
+
-
          ⇩ after this line
+
-
       
+
-
 
+
-
       
+
-
          Alt->
+
-
          Move in history
+
-
          all the lines
+
-
          ⇩ to the line currently being entered
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-r
+
-
          Incrementally search the line history
+
-
          ⇧ backwardly
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-s
+
-
          Incrementally search the line history
+
-
          ⇩ forwardly
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-J
+
-
          End an incremental search
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-G
+
-
          Abort an incremental search and restore the original line
+
-
       
+
-
 
+
-
       
+
-
          Alt-Ctrl-y
+
-
          Yank/Paste
+
-
          arg. 1 of prev. cmnd
+
-
          at the cursor position
+
-
       
+
-
 
+
-
       
+
-
         
+
-
            Alt-.
+
-
 
+
-
            Alt-_
+
-
         
+
-
          Yank/Paste
+
-
          last arg of prev. cmnd
+
-
          at the cursor position
+
-
       
+
-
     
+
-
 
+
-
     
+
-
       
+
-
          Undo
+
-
         
+
-
            Ctrl-_
+
-
 
+
-
            Ctrl-x
+
-
 
+
-
            Ctrl-u
+
-
         
+
-
          Undo the last editing command; you can undo all the way back to an empty line
+
-
       
+
-
 
+
-
       
+
-
          Alt-r
+
-
          Undo all changes made to this line
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-l
+
-
          Clear the screen, reprinting the current line at the top
+
-
       
+
-
 
+
-
       
+
-
          Ctrl-l
+
-
          Clear the screen, reprinting the current line at the top
+
-
       
+
-
     
+
-
 
+
-
     
+
-
       
+
-
          Completion
+
-
          TAB
+
-
          Auto-complete a name
+
-
       
+
-
 
+
-
       
+
-
          Alt-/
+
-
          Auto-complete a name (without smart completion)
+
-
       
+
-
 
+
-
       
+
-
          Alt-?
+
-
          List the possible completions of the preceeding text
+
-
       
+
-
 
+
-
       
+
-
          Alt-*
+
-
          Insert all possible completions of the preceeding text
+
-
       
+
-
     
+
-
 
+
-
     
+
-
       
+
-
          Transpose
+
-
          Ctrl-t
+
-
          Transpose/drag
+
-
          char. before the cursor
+
-
          ↷ over the character at the cursor
+
-
       
+
-
 
+
-
       
+
-
          Alt-t
+
-
          Transpose/drag
+
-
          word before the cursor
+
-
          ↷ over the word at/after the cursor
+

Version du 25 septembre 2015 à 08:19

La ligne de commande Bash comme beaucoup d'autres applications utilise la librairie readline pour permettre à l'utilisateur de se déplacer sur la ligne de commande, ou bien de l'éditer facilement.

Raccourcis clavier fournis par readline

Ctrl-A Déplacement au début de la ligne
Ctrl-E Déplacement en fin de ligne
Alt-B Déplacement au mot précédent
Alt-F Déplacement au mot suivant
Ctrl-L Effacer l'écran
Ctrl-K Effacer le texte du curseur à la fin de la ligne
Ctrl-U Effacer le texte du début de la ligne au curseur
Ctrl-W Effacer le mot précédant le curseur
Alt-d Effacer le mot apres le curseur
Ctrl-_ Annuler la dernière édition
Ctrl-R Chercher une commande dans l'historique (en arrière)
Ctrl-G Annuler la recherche
Ctrl-V Insertion d'un caractère non imprimable

D'autres raccourcis clavier sont assez utiles, comme

Ctrl-S et Ctrl-Q pour bloquer le terminal et le débloquer,

ce qui est utile pour lire le texte qui défile parfois rapidement.

Cependant, ces raccourcis clavier peuvent être désactivés avec la commande stty -ixon pour avoir accès à la fonction de recherche Ctrl-S (chercher en avant dans l'historique). D'autres raccourcis clavier très courants à mentionner pour rappel: les flèches haut et bas pour naviguer dans l'historique,

Ctrl-C pour interrompre un programme en cours d'exécution,
Ctrl-Z pour le suspendre temporairement (le programme peut être ensuite contrôlé avec les commandes fg et bg),
Ctrl-D pour simuler une fin de fichier pour un programme qui lit les données dans l'entrée standard (par exemple pour terminer la session shell en cours ou pour terminer la composition d'un email avec mail).
  • Les arguments de commande

Alt-Ctrl-y pour coller le premier argument de la commande précédente Alt-3 Alt-Ctrl-y pour coller le 3eme argument de la commande précédente (Alt-X permet de sélectionner un argument)

Outils personnels