Bash: Remove duplicate SSH autocomplete.

This commit is contained in:
Artem Sapegin 2012-11-28 12:41:42 +04:00
parent 67c61baec4
commit c1f4d1730e
2 changed files with 5 additions and 8 deletions

View File

@ -109,16 +109,10 @@ add-ssh-host() {
tput bold; ssh -o PasswordAuthentication=no $identifier true && { tput setaf 2; echo "SSH key added."; } || { tput setaf 1; echo "Failure"; }; tput sgr0 tput bold; ssh -o PasswordAuthentication=no $identifier true && { tput setaf 2; echo "SSH key added."; } || { tput setaf 1; echo "Failure"; }; tput sgr0
_ssh_load_autocomplete _ssh_reload_autocomplete
fi fi
} }
# Adds ~/.ssh/config to the ssh autocomplete
_ssh_load_autocomplete() {
complete -W "$(awk '/^\s*Host\s*/ { sub(/^\s*Host /, ""); print; }' ~/.ssh/config)" ssh
}
_ssh_load_autocomplete
# Upload current directory to special directory on my hosting # Upload current directory to special directory on my hosting
function yay() { function yay() {
server="locum" server="locum"

View File

@ -49,7 +49,10 @@ unset file
command -v brew >/dev/null 2>&1 && [ -r "$(brew --prefix)/etc/bash_completion" ] && source "$(brew --prefix)/etc/bash_completion" command -v brew >/dev/null 2>&1 && [ -r "$(brew --prefix)/etc/bash_completion" ] && source "$(brew --prefix)/etc/bash_completion"
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards # Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
_ssh_reload_autocomplete() {
[ -e "~/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh [ -e "~/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
}
_ssh_reload_autocomplete
# Nano is default editor # Nano is default editor
export EDITOR='nano' export EDITOR='nano'