Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bash-completion for augtool, augmatch, augprint #783

Merged
merged 1 commit into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions augeas.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ rm -rf $RPM_BUILD_ROOT
%doc %{_mandir}/man1/*
%{_datadir}/vim/vimfiles/syntax/augeas.vim
%{_datadir}/vim/vimfiles/ftdetect/augeas.vim
%{bash_completions_dir}/*-completion.bash

%files libs
%defattr(-,root,root,-)
Expand All @@ -126,6 +127,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/libfa.a

%changelog
* Sun Nov 20 2022 George Hansper <[email protected]> - 1.14.0
- add bash completions

* Fri Mar 17 2017 David Lutterkort <[email protected]> - 1.8.0-1
- add static subpackage

Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,8 @@ AC_OUTPUT(Makefile \
doc/Makefile \
doc/naturaldocs/Makefile \
augeas.pc augeas.spec)

# Bash completion ...
PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], ,
bashcompdir="${sysconfdir}/bash_completion.d")
AC_SUBST(bashcompdir)
5 changes: 5 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ FORCE-datadir.h: Makefile
$(top_srcdir)/build/ac-aux/move-if-change datadir.h1 datadir.h

datadir.h: FORCE-datadir.h

#bashcompdir = @bashcompdir@
bashcompdir = $(datadir)/bash-completion/completions
dist_bashcomp_DATA = augtool-completion.bash augmatch-completion.bash augprint-completion.bash

33 changes: 33 additions & 0 deletions src/augmatch-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# bash completion for augtool -*- shell-script -*-

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

case $prev in
--help | -!(-*)[h])
return
;;
--lens | -!(-*)[l])
local lenses
lenses="$(augtool --noload 'match /augeas/load/*/lens' | sed -e 's/.*@//')"
COMPREPLY=($(compgen -W "${lenses,,}" -- "${cur,,}"))
return
;;
--root | --include | -!(-*)[rI])
_filedir -d
return
;;
esac

if [[ "$cur" == -* ]]; then
local opts="$(_parse_help "$1")"
COMPREPLY=($(compgen -W '${opts:-$(_parse_help "$1")}' -- "$cur"))
else
_filedir
fi
} &&
complete -F _augmatch augmatch

# ex: filetype=sh
33 changes: 33 additions & 0 deletions src/augprint-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# bash completion for augtool -*- shell-script -*-

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

case $prev in
--help | --version | -!(-*)[hV])
return
;;
--target | -!(-*)[t])
_filedir
return
;;
--lens | -!(-*)[l])
local lenses
lenses="$(augtool --noload 'match /augeas/load/*/lens' | sed -e 's/.*@//')"
COMPREPLY=($(compgen -W "${lenses,,}" -- "${cur,,}"))
return
;;
esac

if [[ "$cur" == -* ]]; then
local opts="$(_parse_help "$1")"
COMPREPLY=($(compgen -W '${opts:-$(_parse_help "$1")}' -- "$cur"))
else
_filedir
fi
} &&
complete -F _augprint augprint

# ex: filetype=sh
29 changes: 29 additions & 0 deletions src/augtool-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# bash completion for augtool -*- shell-script -*-

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

case $prev in
--help | --version | -!(-*)[hV])
return
;;
--load-file | --file | -!(-*)[lf])
_filedir
return
;;
--root | --include | -!(-*)[rI])
_filedir -d
return
;;
esac

if [[ "$cur" == -* ]]; then
local opts="$(_parse_help "$1")"
COMPREPLY=($(compgen -W '${opts:-$(_parse_help "$1")}' -- "$cur"))
fi
} &&
complete -F _augtool augtool

# ex: filetype=sh