简体   繁体   English

如何根据要搜索的字符串的不同属性在bash中使用制表符补全?

[英]How can I use tab completion in bash based on different attributes of the string I am searching?

Right now, I am in the directory migrate in my current Rails project, and have the following migrations: 现在,我在当前的Rails项目中进行目录migrate ,并进行以下迁移:

20140206000143_create_users.rb   20140206032051_create_comments.rb 
20140209232521_create_login.rb   20140206031331_create_photos.rb  
20140206034224_load_data.rb

I want to select 20140209232521_create_login.rb using tab completion but it becomes complicated because I have to pay attention to where the different filenames differ. 我想使用制表符20140209232521_create_login.rb选择20140209232521_create_login.rb但这变得很复杂,因为我必须注意不同文件名的不同之处。 Is there any way to select the file I'm looking for quickly? 有什么方法可以快速选择我要查找的文件?

Thanks! 谢谢!

Not without the bash_completion package installed, but it is fairly rudimentary compared the zsh tab completion. 并非没有安装bash_completion软件包,但与zsh选项卡的完成相比,它是基本的。 The native tab-completion in zsh is streets ahead. zsh中的本机制表符补全位于前面的街道上。 Zsh will cycle through your files with each tab, or you can tab complete wildcards, for example 'vi *users' would expand to 'vi 20140206000143_create_users.rb' Zsh将在每个选项卡中循环浏览文件,或者您也可以使用选项卡完整的通配符,例如“ vi * users”将扩展为“ vi 20140206000143_create_users.rb”

With Bash, using the menu-complete function instead of the normal complete make get you closer to what you want: 使用Bash,使用menu-complete功能而不是普通complete可以使您更接近所需的内容:

bind C-i:menu-complete

With this setting, pressing the <tab> key will cycle between possible completions. 使用此设置,按<tab>键将在可能的完成之间循环。

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

相关问题 如何使 bash 选项卡完成的行为类似于 vim 选项卡完成并循环匹配匹配项? - How can I make bash tab completion behave like vim tab completion and cycle through matching matches? 如何对别名使用Bazel bash自动补全功能? - How do I use Bazel bash auto-completion for aliases? 如何使用制表符完成替换命令行参数? - How can I replace a command line argument with tab completion? 如何在选项卡完成期间在 OS X Lion 上获取 bash 以忽略.DS_Store 文件? - How do I get bash on OS X Lion to ignore .DS_Store files during tab completion? 我如何在bash函数的字符串中使用参数 - How can I use an argument in a string in a bash function 如何从其他路径启用bash选项卡完成? - How do I enable bash tab complete from a different path? Linux bash:如何根据另一行/不同行上的模式替换一行上的字符串? - Linux bash: How do I replace a string on a line based on a pattern on another/different line? 在Bash中,我怎么知道我目前是否在终端 - In Bash, how can I tell if I am currently in a terminal 每当我找到相同的String时,如何浏览文件并设置数组? 我正在使用bash代码进行编程 - How can I look through a file and set an array for each time I found the same String? I am programming with bash code 基于第一个值的不同选项的 bash 完成 - bash completion with different options based on first value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM