Answers:
有时候这很有用...
例
使用ssh连接到另一台机器:
开始打字
ssh
使用PgUp键,您的ssh会以您上次使用的键结束。PgUp再次按,它会显示下一个,依此类推。喜欢它?
您可以使用此:
编辑您的.bashrc(vi /home/<yourfolder>/.bashrc)并添加以下内容:
$if Bash
# Search history back and forward using page-up and page-down
"\e[5~": history-search-backward
"\e[6~": history-search-forward
# Completion
set match-hidden-files off
set page-completions off
set completion-query-items 350
set show-all-if-ambiguous on
$endif
这只会在您的用户终端上添加此功能。您还必须编辑其中的一个以使其具有相同的内容:您可以从Wiki上遵循本教程,这是不可能做错的,还有很多额外的东西可以改善您的终端体验...
bind '"\e[A": history-search-backward'; bind '"\e[B": history-search-forward',使其更加直观。
实现您想要的最简单的方法是!<whatever-command>。例如ls,要执行最后执行的操作,可以执行!ls。查看以下日志,看看这是否是您所需要的:
nits@nits-excalibur:~$ ls /mnt/Storage_1/Music/
Music I Music II Music III Music IV Music V Music_VI
nits@nits-excalibur:~$ cd Documents/
nits@nits-excalibur:~/Documents$ top
nits@nits-excalibur:~/Documents$ !ls
ls /mnt/Storage_1/Music/
Music I Music II Music III Music IV Music V Music_VI
setopt HIST_VERIFY将命令放置在输入缓冲区中,您可以在其中按Enter接受它或对其进行编辑。
历史记录位于〜/ .bash_history另外,要搜索整洁的bash历史记录,请按ctrl + r,然后键入要查找的命令的开头,以获取巧妙的技巧。
和http://ubuntuforums.org/showthread.php?t=204382以获得方便的命令行别名和技巧
CTRL+R快捷命令。