简体   繁体   中英

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:

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. 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. The native tab-completion in zsh is streets ahead. 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'

With Bash, using the menu-complete function instead of the normal complete make get you closer to what you want:

bind C-i:menu-complete

With this setting, pressing the <tab> key will cycle between possible completions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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