Sha256: 8dffb650765a5c3942fa3d4ef5c58de758804456b8547547307c133360218588

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

# bin/aia_completion.sh
# Setup a prompt completion for use with
# aia (a Ruby program) AI Assistant
#

if [ -z "$PROMPTS_DIR" ]; then
    echo "Error: PROMPTS_DIR environment variable is not set"
    exit 1
fi

# SMELL: Is this BASH-only or will it work with other shells?

# Function to generate prompt completions for aia

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

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

  # Change directory to the prompts directory
  cd $PROMPTS_DIR

  # 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"

  # Generate possible matches and store them in the COMPREPLY array
  COMPREPLY=($(compgen -W "${files[*]}" -- "$cur_word"))
}


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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aia-0.3.0 bin/aia_completion.sh
aia-0.0.5 bin/aia_completion.sh
aia-0.0.4 bin/aia_completion.sh
aia-0.0.3 bin/aia_completion.sh