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?
Best Answer
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: