From e4f27632a028c73c0b0e863d68eb63b897f7eea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Apeland?= Date: Sat, 31 Oct 2020 15:40:23 +0100 Subject: [PATCH] contrib: bash: completion.bash: add completion for lsbtr --- Makefile | 3 +++ contrib/bash/completion.bash | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Makefile b/Makefile index 118286f..e3346d0 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,9 @@ install-completion: @echo 'installing bash completion...' install -d -m 755 "$(DESTDIR)$(BASHCOMPDIR)" install -p -m 644 contrib/bash/completion.bash "$(DESTDIR)$(BASHCOMPDIR)/$(BIN)" + for name in $(BIN_LINKS); do \ + ln -s -n -f $(BIN) "$(DESTDIR)$(BASHCOMPDIR)/$$name"; \ + done install-systemd: @echo 'installing systemd service units...' diff --git a/contrib/bash/completion.bash b/contrib/bash/completion.bash index 2a68d51..558ed45 100644 --- a/contrib/bash/completion.bash +++ b/contrib/bash/completion.bash @@ -106,4 +106,32 @@ _btrbk() fi } && complete -F _btrbk btrbk +_lsbtr() +{ + local cur prev words cword split + _init_completion -s || return + + case "$prev" in + '-c' | '--config') + _filedir + return + ;; + '--override') + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + else + # |... + _filedir -d + return + fi +} && complete -F _lsbtr lsbtr + # ex: filetype=bash