Skip to content

Commit

Permalink
.bash_profile: Support hostname aliases defined in ~/.ssh/config
Browse files Browse the repository at this point in the history
`~/.ssh/config` allows for the usage of hostname aliases, formatted as follows:

    Host first_alias second_alias third_alias
    HostName foo.example.com

This change makes sure these aliases are parsed out individually and added to the autocomplete list.

Ref. mathiasbynens#178.
  • Loading branch information
Nate Ober authored and marknorgren committed Apr 21, 2014
1 parent f91a42a commit 9e56800
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion .bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for option in autocd globstar; do
done

# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh

# Add tab completion for `defaults read|write NSGlobalDomain`
# You could just use `-g` instead, but I like being explicit
Expand Down

0 comments on commit 9e56800

Please sign in to comment.