Sha256: 72685855730911bbb0999bd26c9cd10c97a220db1ede7a5840cffd7f2a0046f8

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

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

function __fish_aia_complete
  # Get the command line and current token
  set -l cmd_line (commandline -opc)
  set -l current_token (commandline -ct)
  
  # Check if we are currently completing the option that requires prompt IDs
  if set -q cmd_line[2]
    # Change directory to the prompts directory
    if test -d $PROMPTS_DIR
      pushd $PROMPTS_DIR
      # Generate completions based on .txt files in the PROMPTS_DIR directory
      for file in (find . -name "*.txt" -type f)
        set file (string replace -r '\.txt$' '' -- $file)
        set file (string replace -r '^\./' '' -- $file)
        printf "%s\n" $file
      end
      popd
    end
  else
    # Use the default file completion if we are not completing a prompt ID
    complete -f -c aia -a "(commandline -ct)"
  end
end

# Register the completion function for the aia command
complete -c aia -a '(__fish_aia_complete)' -f


Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
aia-0.5.0 lib/aia/aia_completion.fish
aia-0.4.4 lib/aia/aia_completion.fish
aia-0.4.3 lib/aia/aia_completion.fish
aia-0.4.2 lib/aia/aia_completion.fish
aia-0.4.1 lib/aia/aia_completion.fish
aia-0.3.20 lib/aia/aia_completion.fish
aia-0.3.19 lib/aia/aia_completion.fish
aia-0.3.4 lib/aia/aia_completion.fish
aia-0.3.3 lib/aia/aia_completion.fish