diff --git a/completion.bash b/completion.bash new file mode 100644 index 0000000..2524e79 --- /dev/null +++ b/completion.bash @@ -0,0 +1,33 @@ +#!/bin/bash + +_manage_completion() { + local cur prev commands + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + # Define available commands + commands="help new edit iedit" + + case "$prev" in + edit|iedit) + # Provide completion for existing song names (directories in content/) + COMPREPLY=( $(compgen -W "$(ls -1 content/ 2>/dev/null)" -- "$cur") ) + return 0 + ;; + new) + # No completion for "new" since it's a new name + return 0 + ;; + esac + + # Default command completion + if [[ $COMP_CWORD -eq 1 ]]; then + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + fi +} + +# Register the completion function for 'manage' +complete -F _manage_completion manage +complete -F _manage_completion ./manage +