Use proper Bash completion.

This commit is contained in:
Scott Wallace 2016-02-29 11:52:27 +00:00
parent ece47778c0
commit 25a74facd5
3 changed files with 5 additions and 29 deletions

View file

@ -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
#--------------------------------------------------------------------------------

View file

@ -67,8 +67,9 @@ fi
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
# Add bash completion scripts # Add bash completion scripts
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
for FILE in /usr/local/etc/bash_completion.d/*; do source ${FILE}; done if [ -f $(brew --prefix)/etc/bash_completion ]; then
for FILE in ~/.bash/auto_complete.d/*; do source ${FILE}; done . $(brew --prefix)/etc/bash_completion
fi
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------

View file

@ -16,6 +16,7 @@ function install_linux_software {
xargs sudo ${INSTALLCMD} <<-EOF xargs sudo ${INSTALLCMD} <<-EOF
ack ack
bash-completion
git git
htop htop
mosh mosh
@ -38,6 +39,7 @@ function install_osx_software {
#------------------------------- #-------------------------------
xargs brew install <<-EOF xargs brew install <<-EOF
ack ack
bash-completion
git git
coreutils coreutils
htop-osx htop-osx