Bash history search

Molto comodo, usando il terminale, poter cominciare a scrivere un comando già usato in passato e scorrendo con la freccia da tastiera, poterlo recuperare al volo senza dover tornare su 2 o 300 volte!

Per poter fare questo è necessario (su osx ma credo che valga anche per linux) creare (se non esiste) nella propria home il file .inputrc e al suo interno copiare quanto segue:

# set show-all-if-ambiguous on

# do not bell on tab-completion
set bell-style none

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on

# show file types while completing
set visible-stats on

# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on

# Only show ‘show all nn items’ for > 1000
set completion-query-items 1000

$if mode=emacs

# for linux console and RH/Debian xterm
“\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5~": history-search-backward
"\e[6~": history-search-forward

# for rxvt
"\e[8~": end-of-line

# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line

$endif

# [Up] and [Down] do incremental history search
“\e[A": history-search-backward
"\e[B": history-search-forward

# Previous stops [Left] and [Right] working: reinstate
“\e[C”: forward-char
“\e[D”: backward-char

$if Bash
# Do expansion when space is pressed
Space: magic-space
$endif

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • RSS
  • StumbleUpon
  • Twitter
  • Reddit

Post a comment