completions/{ssh,rake,capistrano}: Do not rewrite COMP_WORDBREAKS

Fix https://github.com/ohmybash/oh-my-bash/issues/471
This commit is contained in:
Koichi Murase
2023-10-01 04:44:05 +09:00
parent cd8b4d2885
commit 3da4bf6431
4 changed files with 81 additions and 9 deletions

View File

@@ -1,9 +1,12 @@
#! bash oh-my-bash.module
# Bash completion support for Capistrano.
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_omb_module_require lib:omb-completion
function _omb_completion_cap {
local cur
_omb_completion_reassemble_breaks :
if [[ -f Capfile ]]; then
local recent=$(ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1)
if [[ $recent != '.cap_tasks~' ]]; then
@@ -15,9 +18,10 @@ function _omb_completion_cap {
cap --all --tasks | cut -d " " -f 2 > .cap_tasks~
fi
fi
COMPREPLY=($(compgen -W '$(< .cap_tasks)' -- "${COMP_WORDS[COMP_CWORD]}"))
return 0
COMPREPLY=($(compgen -W '$(< .cap_tasks)' -- "$cur"))
fi
_omb_completion_resolve_breaks
}
complete -o default -o nospace -F _omb_completion_cap cap

View File

@@ -1,17 +1,21 @@
#! bash oh-my-bash.module
# Bash completion support for Rake, Ruby Make.
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_omb_module_require lib:omb-completion
function _omb_completion_rake {
local cur
_omb_completion_reassemble_breaks :
if [[ -f Rakefile ]]; then
local recent=$(ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1)
if [[ $recent != '.rake_tasks~' ]]; then
rake --silent --tasks --all | cut -d " " -f 2 > .rake_tasks~
fi
COMPREPLY=($(compgen -W '$(< .rake_tasks~)' -- "${COMP_WORDS[COMP_CWORD]}"))
return 0
COMPREPLY=($(compgen -W '$(< .rake_tasks~)' -- "$cur"))
fi
_omb_completion_resolve_breaks
}
complete -o default -o nospace -F _omb_completion_rake rake

View File

@@ -1,10 +1,12 @@
#! bash oh-my-bash.module
# Bash completion support for ssh.
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_omb_module_require lib:omb-completion
function _omb_completion_ssh {
local cur=${COMP_WORDS[COMP_CWORD]}
local cur
_omb_completion_reassemble_breaks :
if [[ $cur == *@* ]] ; then
local -a options=(-P "${cur%%@*}@" -- "${cur#*@}")
else
@@ -28,7 +30,7 @@ function _omb_completion_ssh {
COMPREPLY+=($(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{for (i=2; i<=NF; i++) print $i}' )" "${options[@]}"))
fi
return 0
_omb_completion_resolve_breaks
}
complete -o default -o nospace -F _omb_completion_ssh ssh scp