#!/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