Adicione o seguinte a ~/.inputrc
:
"\e[B": history-search-forward
"\e[A": history-search-backward
Eu usei isso por um bom tempo agora, portanto, infelizmente, não posso creditar a fonte.
OK. Eu tenho um antigo G5 rodando o Leopard e um Dell rodando o Ubuntu 10.04 em casa e um MacPro também rodando o Leopard no trabalho.
Eu uso muito o Terminal.app/bash. No meu G5 em casa, ele exibe um recurso interessante: usando ↑
para navegar no histórico, recebo o último comando, começando com as poucas letras que eu digitei.
Isso é o que quero dizer ( |
representa o cursor):
$ ssh user@server
$ vim /some/file/just/to/populate/history
$ ss|
Então, eu digitei as duas primeiras letras de "ssh", atingindo ↑
nos resultados:
$ ssh user@server
em vez disso, que é o comportamento que obtenho em qualquer outro lugar:
$ vim /some/file/just/to/populate/history
Se eu continuar exibindo ↑
ou ↓
, posso navegar pelo histórico de ssh
da seguinte forma:
$ ssh otheruser@otherserver
$ ssh user@server
$ ssh yetanotheruser@yetanotherserver
Funciona da mesma forma para qualquer comando como cat
, vim
ou qualquer outra coisa.
Isso é muito legal. Exceto que não tenho ideia de como imitar esse comportamento em minhas outras máquinas.
Aqui está meu .profile
:
export PATH=/Developer/SDKs/flex_sdk_3.4/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/sw/bin:/sw/sbin:/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:$HOME/Applications/bin:/usr/X11R6/bin
export MANPATH=/usr/local/share/man:/usr/local/man:opt/local/man:sw/share/man
export INFO=/usr/local/share/info
export PERL5LIB=/opt/local/lib/perl5
export PYTHONPATH=/opt/local/bin/python2.7
export EDITOR=/opt/local/bin/vim
export VISUAL=/opt/local/bin/vim
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
export LS_COLORS='no=00:fi=00:di=01;34:ln=target:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.deb=00;31:*.rpm=00;31:*.TAR=00;31:*.TGZ=00;31:*.ARJ=00;31:*.TAZ=00;31:*.LZH=00;31:*.ZIP=00;31:*.Z=00;31:*.Z=00;31:*.GZ=00;31:*.BZ2=00;31:*.DEB=00;31:*.RPM=00;31:*.jpg=00;35:*.png=00;35:*.gif=00;35:*.bmp=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.png=00;35:*.fli=00;35:*.gl=00;35:*.dl=00;35:*.psd=00;35:*.JPG=00;35:*.PNG=00;35:*.GIF=00;35:*.BMP=00;35:*.PPM=00;35:*.TGA=00;35:*.XBM=00;35:*.XPM=00;35:*.TIF=00;35:*.PNG=00;35:*.FLI=00;35:*.GL=00;35:*.DL=00;35:*.PSD=00;35:*.mpg=00;36:*.avi=00;36:*.mov=00;36:*.flv=00;36:*.divx=00;36:*.qt=00;36:*.mp4=00;36:*.m4v=00;36:*.MPG=00;36:*.AVI=00;36:*.MOV=00;36:*.FLV=00;36:*.DIVX=00;36:*.QT=00;36:*.MP4=00;36:*.M4V=00;36:*.txt=00;32:*.rtf=00;32:*.doc=00;32:*.odf=00;32:*.rtfd=00;32:*.html=00;32:*.css=00;32:*.js=00;32:*.php=00;32:*.xhtml=00;32:*.TXT=00;32:*.RTF=00;32:*.DOC=00;32:*.ODF=00;32:*.RTFD=00;32:*.HTML=00;32:*.CSS=00;32:*.JS=00;32:*.PHP=00;32:*.XHTML=00;32:'
export LC_ALL=C
export LANG=C
stty cs8 -istrip -parenb
bind 'set convert-meta off'
bind 'set meta-flag on'
bind 'set output-meta on'
alias ip='curl http://www.whatismyip.org | pbcopy'
alias ls='ls -FhLlGp'
alias la='ls -AFhLlGp'
alias couleurs='$HOME/Applications/bin/colors2.sh'
alias td='$HOME/Applications/bin/todo.sh'
alias scale='$HOME/Applications/bin/scale.sh'
alias stree='$HOME/Applications/bin/tree'
alias envoi='$HOME/Applications/bin/envoi.sh'
alias unfoo='$HOME/Applications/bin/unfoo'
alias up='cd ..'
alias size='du -sh'
alias lsvn='svn list -vR'
alias jsc='/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc'
alias asl='sudo rm -f /private/var/log/asl/*.asl'
alias trace='tail -f $HOME/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt'
alias redis='redis-server /opt/local/etc/redis.conf'
source /Users/johncoltrane/Applications/bin/git-completion.sh
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="verbose git"
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1='\n\[3[32m\]\w\[3[0m\] $(__git_ps1 "[%s]")\n\[3[1;31m\]\[3[31m\]\u\[3[0m\] $ \[3[0m\]'
mkcd () {
mkdir -p "$*"
cd "$*"
}
function cdl {
cd $1
la
}
n() {
$EDITOR ~/Dropbox/nv/"$*".txt
}
nls () {
ls -c ~/Dropbox/nv/ | grep "$*"
}
copy(){
curl -s -F 'sprunge=<-' http://sprunge.us | pbcopy
}
if [ -f /opt/local/etc/profile.d/cdargs-bash.sh ]; then
source /opt/local/etc/profile.d/cdargs-bash.sh
fi
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
Alguma ideia?