client/systemd-helper/Makefile
client/snbk/Makefile
scripts/Makefile
+ scripts/completion/Makefile
pam/Makefile
data/Makefile
doc/Makefile
# Makefile.am for snapper/scripts
#
+SUBDIRS = completion
+
if HAVE_PAM
pam_snapperdir = /usr/lib/pam_snapper
endif
-EXTRA_DIST = snapper-hourly bash-completion.bash zsh-completion.zsh $(pam_snapper_SCRIPTS)
+EXTRA_DIST = snapper-hourly $(pam_snapper_SCRIPTS)
install-data-local:
install -D snapper-hourly $(DESTDIR)/etc/cron.hourly/suse.de-snapper
- install -D --mode a+r,u+w bash-completion.bash $(DESTDIR)/usr/share/bash-completion/completions/snapper
- install -D --mode a+r,u+w zsh-completion.zsh $(DESTDIR)/usr/share/zsh/site-functions/_snapper
--- /dev/null
+#
+# Makefile.am for snapper/completion/scripts
+#
+
+EXTRA_DIST = snapper-completion.bash snapper-completion.zsh snbk-completion.bash
+
+install-data-local:
+ install -D --mode a+r,u+w snapper-completion.bash $(DESTDIR)/usr/share/bash-completion/completions/snapper
+ install -D --mode a+r,u+w snapper-completion.zsh $(DESTDIR)/usr/share/zsh/site-functions/_snapper
+ install -D --mode a+r,u+w snbk-completion.bash $(DESTDIR)/usr/share/bash-completion/completions/snbk
--- /dev/null
+# snbk(8) autocompletion
+
+_snbk()
+{
+ local configdir="/etc/snapper/backup-configs"
+ local cur prev words cword
+ _init_completion || return
+
+ local GLOBAL_SNBK_OPTIONS='
+ -q --quiet
+ -v --verbose
+ --utc
+ --iso
+ -t --table-style
+ --machine-readable
+ --csvout
+ --jsonout
+ --separator
+ --no-headers
+ -b --backup-config
+ --no-dbus
+ --target-mode
+ --automatic
+ --version
+ --help
+ '
+
+ # see if the user selected a command already
+ local COMMANDS=(
+ "list-configs"
+ "list" "ls"
+ "transfer"
+ "delete"
+ "transfer-and-delete")
+
+ local command i
+ for (( i=0; i < ${#words[@]}-1; i++ )); do
+ # Match word only either from start of string or after space to prevent options
+ # like -c from matching commands that have -c in them, like list-configs
+ if [[ ${COMMANDS[@]} =~ (^| )"${words[i]}" ]]; then
+ command=${words[i]}
+ break
+ fi
+ done
+
+ # Global options autocomplete
+ case $prev in
+ --version|--help)
+ return 0
+ ;;
+ --backup-config|-b)
+ local configs=()
+ # Get basenames of config files in "$configdir"
+ for configfile in "$configdir"/*.json; do
+ configfile="${configfile##*/}"
+ configfile="${configfile%.*}"
+ configs+=("${configfile}")
+ done
+ COMPREPLY=( $( compgen -W "${configs[*]}" -- "$cur" ) )
+ return 0
+ ;;
+ --machine-readable)
+ COMPREPLY=( $( compgen -W 'csv json' -- "$cur" ) )
+ return 0
+ ;;
+ esac
+
+ # supported options per command
+ if [[ "$cur" == -* ]]; then
+ case $command in
+ *)
+ COMPREPLY=( $( compgen -W "$GLOBAL_SNBK_OPTIONS" -- "$cur" ) )
+ return 0
+ ;;
+ esac
+ fi
+
+ # no command yet, show what commands we have
+ if [ "$command" = "" ]; then
+ #COMPREPLY=( $( compgen -W '${COMMANDS[@]} ${GLOBAL_SNBK_OPTIONS[@]}' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W "${COMMANDS[*]}" -- "$cur" ) )
+ fi
+
+ return 0
+} &&
+complete -F _snbk snbk
#
# spec file for package snapper
#
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
%endif
%{_datadir}/dbus-1/system.d/org.opensuse.Snapper.conf
%{_datadir}/dbus-1/system-services/org.opensuse.Snapper.service
-%{_datadir}/bash-completion
-%{_datadir}/zsh
+%dir %{_datadir}/bash-completion
+%dir %{_datadir}/bash-completion/completions/
+%{_datadir}/bash-completion/completions/snapper
+%dir %{_datadir}/zsh
+%dir %{_datadir}/zsh/site-functions
+%{_datadir}/zsh/site-functions/_snapper
%package -n libsnapper@LIBVERSION_MAJOR@
Summary: Library for filesystem snapshot management
%{_unitdir}/snapper-{backup}.*
%{_mandir}/*/snbk.8*
%{_mandir}/*/snapper-backup-configs.5*
+%dir %{_datadir}/bash-completion
+%dir %{_datadir}/bash-completion/completions
+%{_datadir}/bash-completion/completions/snbk
%package -n pam_snapper
Requires: pam