From 2aa2677ab9ad63252acc1ddea20119101d92eb45 Mon Sep 17 00:00:00 2001 From: Christopher Bock Date: Thu, 2 Oct 2025 15:53:33 +0200 Subject: completion: history * complete command history-(list|info|undo|redo|rollback). complete the history-id for all but commands but history-list. set complet -o nosort to get the history-ids in a reverse order. --- completions/bash/apt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/completions/bash/apt b/completions/bash/apt index 571c6663b..3bd705a98 100644 --- a/completions/bash/apt +++ b/completions/bash/apt @@ -1,4 +1,5 @@ # Debian apt(8) completion -*- shell-script -*- +# shellcheck shell=bash _apt() { @@ -49,6 +50,7 @@ _apt() "download" "changelog" "moo" "modernize-sources" + "history-list" "history-info" "history-undo" "history-redo" "history-rollback" "depends" "rdepends" "why" "why-not" "policy") @@ -94,7 +96,7 @@ _apt() return 0 ;; list) - COMPREPLY=( $( compgen -W '--installed --upgradable + COMPREPLY=( $( compgen -W '--installed --upgradable --manual-installed -v --verbose -a --all-versions @@ -235,6 +237,12 @@ _apt() -- "$cur" ) ) return 0 ;; + history-info|history-rollback|history-redo|history-undo) + local _historyids=$( apt history-list | + awk '/^(ID|$)/{next};{print$1}' |tac 2> /dev/null ) + COMPREPLY=( $( compgen -W "${_historyids[@]}" -- "$cur" ) ) + return 0 + ;; moo) COMPREPLY=( $( compgen -W 'moo' \ -- "$cur" ) ) @@ -248,6 +256,6 @@ _apt() return 0 } && -complete -F _apt apt +complete -o nosort -F _apt apt # ex: ts=4 sw=4 et filetype=sh -- cgit v1.2.3-70-g09d2