Skip to content

Commit

Permalink
bind: Add option and argument (non-)completions
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 9, 2017
1 parent a4c6763 commit 67e082c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
3 changes: 0 additions & 3 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ complete -A helptopic help
# unalias completes with aliases
complete -a unalias

# bind completes with readline bindings (make this more intelligent)
complete -A binding bind

# type and which complete on commands
complete -c command type which

Expand Down
1 change: 1 addition & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bashcomp_DATA = 2to3 \
autoscan \
avctrl \
badblocks \
bind \
bk \
brctl \
btdownloadheadless.py \
Expand Down
36 changes: 36 additions & 0 deletions completions/bind
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# bash bind completion -*- shell-script -*-

_bind()
{
local cur prev words cword
_init_completion || return

case $prev in
-l|-p|-P|-s|-S|-v|-V|-r|-x|-X)
return
;;
-m)
COMPREPLY=( $( compgen -W "emacs emacs-standard emacs-meta
emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur" ) )
return
;;
-f)
_filedir
return
;;
-q|-u)
COMPREPLY=( $( compgen -W '$( "$1" -l )' -- "$cur" ) )
return
;;
esac

if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
return
fi

COMPREPLY=( $( compgen -A binding -- "$cur" ) )
} &&
complete -F _bind bind

# ex: filetype=sh
1 change: 1 addition & 0 deletions test/completion/bind.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assert_source_completions bind
21 changes: 21 additions & 0 deletions test/lib/completions/bind.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
proc setup {} {
save_env
}


proc teardown {} {
assert_env_unmodified
}


setup


assert_complete_any "bind -"
sync_after_int

assert_complete_any "bind k"
sync_after_int


teardown

0 comments on commit 67e082c

Please sign in to comment.