Skip to content

Commit

Permalink
.bash_profile: Support multiple hosts in SSH completion
Browse files Browse the repository at this point in the history
Useful in cases such as:

```

Host vm1 vm2 vm3 vm4
     Host localhost
     # ...
```

Simply adding a `-` to `tr` fixes this.

Closes mathiasbynens#437.
  • Loading branch information
emilbayes authored and mathiasbynens committed Oct 30, 2014
1 parent 91be10d commit fecb8c6
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 @@ -38,7 +38,7 @@ if type _git &> /dev/null && [ -f /usr/local/etc/bash_completion.d/git-completio
fi;

# 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 | tr ' ' '\n')" 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 fecb8c6

Please sign in to comment.