Add: bash completion
This commit is contained in:
parent
3226d93cc2
commit
cdd512f3df
33
completion.bash
Normal file
33
completion.bash
Normal file
@ -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
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user