5 ms·
The poor man’s Bash Tab-completion
- ivanstojic 17y agoThe "dynamic" example: complete -o default -W "`echo $(cat /path/to/file | grep 'lines i want')`" \ [command] is easier written as complete -o default -W "`echo $(grep 'lines i want' /path/to/file)`" \ [command]
- lallysingh 17y agopipe that grep through | tr '\n' ' ' and you don't need the echo.
- mustpax 17y agoThat makes a lot of sense, thanks for pointing these out. I'm updating the article to reflect these corrections.
- lallysingh 17y agoBtw, your updated version has an unnecessary ` lying near the end.
- mustpax 17y agoCorrected again :) Thanks.
- jokull 17y agoAutocomplete known_hosts: complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
- justinlilly 17y agoor you could just install zsh and the problem is solved.
- mustpax 17y agoIt would be more helpful if you actually described what ZSH does differently that solves the problem without manual configuration.
- 10ren 17y agoI didn't know about the $(...) syntax. I've needed this, and resorted to a script, thinking it couldn't be done in a one-liner. $(command) allows them to be nested arbitrarily, whereas `command` can't nest.
- calcnerd256 17y agoI thought you could escape backticks
- 10ren 17y agoYou're right, that works too. Now I've learnt two things.