Atalhos para buscar no history do BASH

Achei neste blog uma dica pra quem usa BASH (ou mingw ou cygwin):


# By default up/down are bound to previous-history
# and next-history respectively. The following does the
# same but gives the extra functionality where if you
# type any text (or more accurately, if there is any text
# between the start of the line and the cursor),
# the subset of the history starting with that text
# is searched (like 4dos for e.g.).
# Note to get rid of a line just Ctrl-C
"\e[B": history-search-forward
"\e[A": history-search-backward

Copie o bloco acima e cole dentro do seu arquivo ~/.inputrc (crie-o caso não exista).

Ele altera o comportamento das setas p/ cima e p/ baixo do teclado para buscarem no histórico de comandos já digitados. Desta forma se você digitar:

$ svn

E apertar a seta pra cima, somente as linhas que começam com ‘svn’ serão exibidas!

BONUS: se quiser buscar por uma parte de uma linha de comando que contenha uma palavra mas não necessariamente que começa por ela (por exemplo, ‘checkout’) digite CTRL+R e escreva ‘checkout’.

One thought on “Atalhos para buscar no history do BASH

Deixe um Comentário

O seu endereço de email não será publicado Campos obrigatórios são marcados *

*

Você pode usar estas tags e atributos de HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>