From e6e0cb44438d567e35577b0a97ad085c210a2493 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Sat, 30 Nov 2024 08:32:41 +0200 Subject: [PATCH] Add smug.bash autocomplete script --- completions/smug.bash | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 completions/smug.bash diff --git a/completions/smug.bash b/completions/smug.bash new file mode 100644 index 0000000..1ce4376 --- /dev/null +++ b/completions/smug.bash @@ -0,0 +1,15 @@ +#!/bin/bash + +_smug() { + local cur + cur="${COMP_WORDS[COMP_CWORD]}" + + if [[ $COMP_CWORD -ge 2 ]]; then + COMPREPLY=() + return 0 + fi + # List files in $HOME/.config/smug/ with .yml extension, removing the extension + COMPREPLY=($(compgen -W "$(find "$HOME/.config/smug/" -maxdepth 1 -name '*.yml' -exec basename {} .yml \;)" -- "$cur")) +} + +complete -F _smug smug