[英]How to make bash tab-completion work like windows' cmd.exe?
Say I have a folder with files in it with names like this: 假设我有一个包含文件的文件夹,其名称如下:
log_1.log
log_2.log
log_2.gz
And I want to perform some operation, let's say move, on log_2.gz. 我想在log_2.gz上执行一些操作,比如说移动。
In Windows cmd.exe, I am used to performing these steps: 在Windows cmd.exe中,我习惯于执行以下步骤:
move
(and nothing else) move
(没有别的) log_2.gz
log_2.gz
destination
destination
But in bash shell (within iTerm2 on Mac OS X 10.8.3), I have to do something like this: 但是在bash shell中(在Mac OS X 10.8.3上的iTerm2中),我必须做这样的事情:
mv l
mv l
log_
and makes an annoying beep sound log_
并发出恼人的哔哔声 2
2
log_2.
log_2.
and makes an annoying beep sound g
g
log_2.gz
and is satisfyingly silent log_2.gz
我到log_2.gz
并且令人满意地保持沉默 destination
destination
As you can see, bash requires many more steps even when you know the destination filename, but imagine a scenario where you are not really certain what exactly is in the filename (maybe the ls
was too long). 正如您所看到的,即使您知道目标文件名,bash也需要更多步骤,但想象一下您不确定文件名究竟是什么的场景(可能是
ls
太长)。 I often find myself in this scenario after a few tab + typing and am forced to abandon the command, run ls
again, copy the filename, maybe even run a pwd
to concatenate with the folder, and then resume where I left off. 我经常发现自己在这个场景中经过一些标签 +打字并被迫放弃命令,再次运行
ls
,复制文件名,甚至可以运行pwd
与文件夹连接,然后从我离开的地方继续。 This is very annoying. 这非常烦人。
You can add the following in your .inputrc
(if you don't have one, then create it) file. 您可以在
.inputrc
添加以下内容(如果您没有,则创建它)文件。 Once added, either source the file or logout and log back in. 添加后,请获取文件或注销并重新登录。
set show-all-if-ambiguous on
set completion-ignore-case on
TAB: menu-complete
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.