Sha256: bc76c054a702fb32b45fca55147ee8eb99b97a7fc325bc5c8f3211d190c65ebd

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

# lib/aia/aia_completion.zsh
# Setup a prompt completion for use with
# the zsh 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="$words[$CURRENT]"

  # The previous word before the current word
  local prev_word="$words[$CURRENT-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 an array
    _describe 'prompt ID' files
  else
    # If not the specific option, use the standard filename completion
    _files
  fi
}

# Register the completion function for the aia command using compctl
compctl -K _aia_completion aia

Version data entries

15 entries across 15 versions & 1 rubygems

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