Skip to content

[FEATURE] improve bash completion script #3633

@ipariparipa

Description

@ipariparipa
# Bash completion script for QOwnNotes
_QOwnNotes() {
  COMPREPLY=()
  local current="${COMP_WORDS[COMP_CWORD]}"
  local prev="${COMP_WORDS[COMP_CWORD-1]}"
  _init_completion || return
  local commands="--h --help --portable --dump-settings --version --allow-multiple-instances --clear-settings --session --action --completion --decrypt-note --decrypt-note-password "
  if [[ "$prev" == "--decrypt-note" ]]; then
      compopt -o filenames
      _filedir
      return 0
  fi
  if [[ "$prev" == "--decrypt-note-password" ]]; then
      return 0
  fi
  if [[ "$prev" == "--session" ]]; then
      return 0
  fi
  if [[ "$prev" == "--action" ]]; then
      return 0
  fi
  if [[ "$prev" == "--completion" ]]; then
      COMPREPLY=( $(compgen -W "bash fish" -- "$current") )
      return 0
  fi

  COMPREPLY=( $(compgen -W "${commands}" -- ${current}) )
  return 0
}
complete -F _QOwnNotes QOwnNotes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions