diff --git a/includes/bash_functions.bash b/includes/bash_functions.bash index ddaea2d..5db1e63 100644 --- a/includes/bash_functions.bash +++ b/includes/bash_functions.bash @@ -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 - _ssh_load_autocomplete + _ssh_reload_autocomplete 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 function yay() { server="locum" diff --git a/tilde/bash_profile.bash b/tilde/bash_profile.bash index d7a6b77..8e65d89 100644 --- a/tilde/bash_profile.bash +++ b/tilde/bash_profile.bash @@ -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" # Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards -[ -e "~/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh +_ssh_reload_autocomplete() { + [ -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 export EDITOR='nano'