I have web projects in /var/www/projects/some/long/path/strange-project-name
Now I want to type in terminal:
webs str{TAB}
It should autocomplete to the webs strange-project-name
(basing on ls /var/www/projects/some/long/path/
) and after executing the command, the pwd
should point to project path. Kind of smart cd strange-project-name
with autocomplete
How would you implement this feature? Some smart alias? Function in .bashrc
? Script?
Some smart alias?
You would need a two-parter. One, a completion script:
_get_cword
depends on the bash-completions package being installed. If you don't have it then change the line:to:
Two, a function:
I'm not sure if this is what you need...
in terminal...
find this rows and uncomment it:
now you can auto complete commands from your history with page up/down
I would create a custom bash autocompletion script for that. Take a look at
/etc/bash_completion.d
directory and its numerous examples. Then create a file calledwebs
to that directory and adapt it to your needs.Correct me if I'm wrong, but I think this is exactly what Lightning was created for. It's a Ruby project, so this isn't a good answer if using Bash is a goal in itself.