Files
linux-backuper/completions/bash/linux-backuper
T
2026-10-09 20:22:51 +02:00

159 lines
5.4 KiB
Plaintext

# bash completion for linux-backuper
# Generated automatically by linux-backuper completion bash
_linux_backuper_get_snapshots() {
local backup_dir="/var/backups/linux-backuper"
if [[ -d "$backup_dir" ]]; then
find "$backup_dir" -maxdepth 1 -name "backup_*.tar.gz" -exec basename {} .tar.gz \; 2>/dev/null
fi
}
_linux_backuper() {
local cur prev words cword
_init_completion || return
local commands="snapshot list show diff extract restore prune push verify completion"
local profiles="quick system full dr"
if [[ $cword -eq 1 ]]; then
COMPREPLY=( $(compgen -W "$commands -h --help -v --version" -- "$cur") )
return 0
fi
local cmd="${words[1]}"
case "$cmd" in
snapshot)
case "$prev" in
--profile)
COMPREPLY=( $(compgen -W "$profiles" -- "$cur") )
return 0
;;
--compression)
COMPREPLY=( $(compgen -W "gzip none" -- "$cur") )
return 0
;;
--target-dir|--config|--pid-path|--ssh-key)
_filedir
return 0
;;
--paths)
_filedir
return 0
;;
esac
local snap_opts="--profile --target-dir --paths --compression --no-compression --sanitize --config --pid-path --keep-last --keep-daily --keep-weekly --keep-monthly --push --ssh-key --remote-keep-last --remote-keep-daily --remote-keep-weekly --remote-keep-monthly --json --verbose -h --help"
COMPREPLY=( $(compgen -W "$snap_opts" -- "$cur") )
return 0
;;
list)
case "$prev" in
--target-dir)
_filedir -d
return 0
;;
esac
COMPREPLY=( $(compgen -W "--target-dir --json --verbose -h --help" -- "$cur") )
return 0
;;
show|verify)
case "$prev" in
show|verify)
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots)" -- "$cur") )
return 0
;;
--target-dir)
_filedir -d
return 0
;;
esac
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots) --packages --files --target-dir --json --verbose -h --help" -- "$cur") )
return 0
;;
diff)
case "$prev" in
--target-dir|--target-root)
_filedir -d
return 0
;;
diff)
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots)" -- "$cur") )
return 0
;;
esac
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots) --target-dir --target-root --unified -u --json --verbose -h --help" -- "$cur") )
return 0
;;
extract)
case "$prev" in
extract)
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots)" -- "$cur") )
return 0
;;
--file)
# File inside snapshot
return 0
;;
--out|--target-dir)
_filedir
return 0
;;
esac
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots) --file --out --target-dir --json --verbose -h --help" -- "$cur") )
return 0
;;
restore)
case "$prev" in
restore)
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots)" -- "$cur") )
return 0
;;
--target-root|--target-dir)
_filedir -d
return 0
;;
esac
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots) --dry-run --force --target-root --include-fstab --target-dir --pid-path --json --verbose -h --help" -- "$cur") )
return 0
;;
prune)
case "$prev" in
--target-dir)
_filedir -d
return 0
;;
esac
COMPREPLY=( $(compgen -W "--keep-last --keep-daily --keep-weekly --keep-monthly --dry-run --force --target-dir --pid-path --json --verbose -h --help" -- "$cur") )
return 0
;;
push)
case "$prev" in
push)
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots)" -- "$cur") )
return 0
;;
--ssh-key|--target-dir|--config)
_filedir
return 0
;;
esac
COMPREPLY=( $(compgen -W "$(_linux_backuper_get_snapshots) --target --ssh-key --remote-keep-last --remote-keep-daily --remote-keep-weekly --remote-keep-monthly --target-dir --config --json --verbose -h --help" -- "$cur") )
return 0
;;
completion)
COMPREPLY=( $(compgen -W "bash zsh" -- "$cur") )
return 0
;;
esac
}
complete -F _linux_backuper linux-backuper