Updated the method for bash completion scripts.
Added bash completion for Git.
This commit is contained in:
parent
c68aaaca16
commit
fbd308270b
2752
.bash/auto_complete.d/git
Normal file
2752
.bash/auto_complete.d/git
Normal file
File diff suppressed because it is too large
Load diff
25
.bash/auto_complete.d/ssh
Normal file
25
.bash/auto_complete.d/ssh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#--------------------------------------------------------------------------------
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -o bashdefault -o default -o nospace -F _ssh ssh 2>/dev/null \
|
||||||
|
|| complete -o default -o nospace -F _ssh ssh
|
||||||
|
#--------------------------------------------------------------------------------
|
24
.bashrc
24
.bashrc
|
@ -63,29 +63,9 @@ export GOPATH=${HOME}/src/go
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
# Add bash completion for ssh: it tries to complete the host to which you
|
# Add bash completion scripts
|
||||||
# want to connect from the list of the ones contained in ~/.ssh/known_hosts
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
__ssh_known_hosts() {
|
for FILE in ~/.bash/auto_complete.d/*; do source ${FILE}; done
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
complete -o bashdefault -o default -o nospace -F _ssh ssh 2>/dev/null \
|
|
||||||
|| complete -o default -o nospace -F _ssh ssh
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
||||||
[ -f ~/.bashrc_local ] && source ~/.bashrc_local
|
[ -f ~/.bashrc_local ] && source ~/.bashrc_local
|
||||||
|
|
Loading…
Reference in a new issue