TmpAccToSayThis·8 lat temu·discussIf you use '~/.ssh/config' with SSH, add this to your '~/.bash_profile' file to add autocompletion for all your servers:complete -f -d -W "$(grep '[Hh]ost ' ~/.ssh/config | grep -v '*' | awk '{print $2}')" ssh scpIf you don't use '~/.ssh/config' but have a '~/.ssh/known_hosts' file, add this instead:complete -f -d -W "$(cut -d',' -f1 ~/.ssh/known_hosts | awk '{print $1}')" ssh scpSimilarly, you can use the 'complete' command in '~/.bash_profile' to tweak everything. Some other ways I use it are:1. Make 'cd' and 'ls' only autocomplete for directories: complete -d cd ls2. Make 'foo' autocomplete with 'bar0' and 'bar1': complete -W 'bar0 bar1' foo
complete -f -d -W "$(grep '[Hh]ost ' ~/.ssh/config | grep -v '*' | awk '{print $2}')" ssh scp
If you don't use '~/.ssh/config' but have a '~/.ssh/known_hosts' file, add this instead:
complete -f -d -W "$(cut -d',' -f1 ~/.ssh/known_hosts | awk '{print $1}')" ssh scp
Similarly, you can use the 'complete' command in '~/.bash_profile' to tweak everything. Some other ways I use it are:
1. Make 'cd' and 'ls' only autocomplete for directories: complete -d cd ls
2. Make 'foo' autocomplete with 'bar0' and 'bar1': complete -W 'bar0 bar1' foo