Last active
July 17, 2020 10:44
-
-
Save nuBacuk/b21e95504e26059eaaf29decd9ce55ed to your computer and use it in GitHub Desktop.
bash ssh autocomplete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| file: ~/.bashrc | |
| . /etc/bash_completion.d/ssh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| file: .ssh/config | |
| Host * | |
| HashKnownHosts no | |
| StrictHostKeyChecking no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| file: /etc/bash_completion.d/ssh | |
| __complete_ssh_host() { | |
| local KNOWN_FILE=~/.ssh/known_hosts | |
| if [ -r $KNOWN_FILE ] ; then | |
| local KNOWN_LIST=`cut -f 1 -d ' ' $KNOWN_FILE | cut -f 1 -d ',' | grep -v '^[0-9[]'` | |
| fi | |
| local PARTIAL_WORD="${COMP_WORDS[COMP_CWORD]}"; | |
| COMPREPLY=( $(compgen -W "$KNOWN_LIST$IFS$CONFIG_LIST" -- "$PARTIAL_WORD") ) | |
| return 0 | |
| } | |
| complete -F __complete_ssh_host ssh | |
| complete -f -F __complete_ssh_host scp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment