简体   繁体   English

Bash选项卡完成像ncftp吗?

[英]Bash tab completion like ncftp?

In ncftp tab completion only shows the differences of matched files. ncftp选项卡中,完成仅显示匹配文件的差异。 Eg with the following files 例如,以下文件

file123 file125 aa

then typing ls fil will first complete to ls file12 and show 然后输入ls fil将首先完成ls file12并显示

3 5 

Question

Can the same be done in Bash? 在Bash中可以做同样的事情吗?

BASH supports tab-completion which is fairly robust. BASH支持制表符补全,它非常健壮。 It is implemented through bash_completion . 它是通过bash_completion实现的。 However, be aware that the way bash_completion is configured will depend on what options are set by default by your distribution. 但是,请注意,配置bash_completion的方式将取决于您的发行版默认设置的选项。 As for its basic functionality, it is exactly as you describe for ncftp . 至于它的基本功能,它与您为ncftp所描述的完全相同。 When a partial name is entered on the command line and tab is pressed, then a list of name-matched files are displayed. 在命令行上输入部分名称并按下tab ,将显示名称匹配文件的列表。 Once you have entered enough characters to make the name unique, tab will complete entry of the unique filename on the command line. 输入足够的字符以使名称唯一后, tab将在命令行中完成唯一文件名的输入。

Linux also provides ls , but its behavior is not the same as you describe for ncftp . Linux还提供了ls ,但是其行为与您为ncftp描述的行为不同。 ls will return the names of files and directories that match the pattern you specified. ls将返回与您指定的模式匹配的文件和目录的名称。 By default, the name you provide to ls is not expanded. 默认情况下,您提供给ls的名称不会扩展。 Meaning if you have file123 and file125 in a directory and issue the command ls file , you will be greeted by the error ls: cannot access bash: No such file or directory . 这意味着如果您在目录中有file123file125并发出命令ls file ,则会遇到错误ls: cannot access bash: No such file or directory ,您将大file125 But providing a wildcard (filename globbing) with ls file* will return both names. 但是为ls file*提供通配符(文件名通配)将返回两个名称。

If you have additional specific questions. 如果您还有其他特定问题。 Just leave a comment and we will do our best to help. 请发表评论,我们将竭尽所能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM