Sha256: 527c458f07675ba1d30b91aa54a22ae53fd12deb85bef4cb5f3ba4c2d416c3a2

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

# lib/aia/aia_completion.bash
# Setup a prompt completion for use with
# the bash shell
#
# This script assumes that the system environment
# variable AIA_PROMPTS_DIR has been set correctly

_aia_completion() {
  # The current word being completed
  local cur_word="${COMP_WORDS[COMP_CWORD]}"

  # The previous word before the current word
  local prev_word="${COMP_WORDS[COMP_CWORD-1]}"

  # Store the previous directory to return to it later
  local initial_pwd=$(pwd)

  # Check if we are currently completing the option that requires prompt IDs
  if [[ "$prev_word" == "aia" ]]; then
    # Change directory to the prompts directory
    cd "$AIA_PROMPTS_DIR" || return

    # Generate a list of relative paths from the ~/.prompts directory (without .txt extension)
    local files=($(find . -name "*.txt" -type f | sed 's|^\./||' | sed 's/\.txt$//'))

    # Change back to the initial directory
    cd "$initial_pwd" || return

    # Generate possible matches and store them in the COMPREPLY array
    COMPREPLY=($(compgen -W "${files[*]}" -- "$cur_word"))
  else
    # If not the specific option, perform regular file completion
    COMPREPLY=($(compgen -o default -- "$cur_word"))
  fi
}

# Register the completion function for the aia command
complete -F _aia_completion aia

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
aia-0.5.18 lib/aia/aia_completion.bash
aia-0.5.16 lib/aia/aia_completion.bash
aia-0.5.15 lib/aia/aia_completion.bash
aia-0.5.14 lib/aia/aia_completion.bash
aia-0.5.13 lib/aia/aia_completion.bash
aia-0.5.12 lib/aia/aia_completion.bash
aia-0.5.11 lib/aia/aia_completion.bash
aia-0.5.10 lib/aia/aia_completion.bash
aia-0.5.9 lib/aia/aia_completion.bash
aia-0.5.8 lib/aia/aia_completion.bash
aia-0.5.7 lib/aia/aia_completion.bash
aia-0.5.6 lib/aia/aia_completion.bash
aia-0.5.3 lib/aia/aia_completion.bash
aia-0.5.2 lib/aia/aia_completion.bash
aia-0.5.1 lib/aia/aia_completion.bash