From 25a74facd5925a2e1fddca62ecde2b8b50585bf6 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Mon, 29 Feb 2016 11:52:27 +0000 Subject: [PATCH] Use proper Bash completion. --- .bash/auto_complete.d/ssh | 27 --------------------------- .bashrc | 5 +++-- bin/software-install.sh | 2 ++ 3 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 .bash/auto_complete.d/ssh diff --git a/.bash/auto_complete.d/ssh b/.bash/auto_complete.d/ssh deleted file mode 100644 index 49bbbc2..0000000 --- a/.bash/auto_complete.d/ssh +++ /dev/null @@ -1,27 +0,0 @@ -#-------------------------------------------------------------------------------- -# Add bash completion for ssh: it tries to complete the host to which you -# want to connect from the list of the ones contained in ~/.ssh/known_hosts -#-------------------------------------------------------------------------------- -__ssh_known_hosts() { - if [[ -f ~/.ssh/known_hosts ]]; then - cut -d " " -f1 ~/.ssh/known_hosts | cut -d "," -f1 - fi -} - -_ssh() { - local cur known_hosts - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - known_hosts="$(__ssh_known_hosts)" - - if [[ ! ${cur} == -* ]] ; then - COMPREPLY=( $(compgen -W "${known_hosts}" -- ${cur}) ) - return 0 - fi -} - -for CMD in ssh scp telnet nc ftp ping curl; do - complete -o bashdefault -o default -o nospace -F _ssh ${CMD} 2>/dev/null \ - || complete -o default -o nospace -F _ssh ${CMD} -done -#-------------------------------------------------------------------------------- diff --git a/.bashrc b/.bashrc index 955b71b..9da39dc 100644 --- a/.bashrc +++ b/.bashrc @@ -67,8 +67,9 @@ fi #-------------------------------------------------------------------------------- # Add bash completion scripts #-------------------------------------------------------------------------------- -for FILE in /usr/local/etc/bash_completion.d/*; do source ${FILE}; done -for FILE in ~/.bash/auto_complete.d/*; do source ${FILE}; done +if [ -f $(brew --prefix)/etc/bash_completion ]; then + . $(brew --prefix)/etc/bash_completion +fi #-------------------------------------------------------------------------------- #-------------------------------------------------------------------------------- diff --git a/bin/software-install.sh b/bin/software-install.sh index 72c939d..e398c7c 100755 --- a/bin/software-install.sh +++ b/bin/software-install.sh @@ -16,6 +16,7 @@ function install_linux_software { xargs sudo ${INSTALLCMD} <<-EOF ack + bash-completion git htop mosh @@ -38,6 +39,7 @@ function install_osx_software { #------------------------------- xargs brew install <<-EOF ack + bash-completion git coreutils htop-osx