Sha256: 25f87e4b21d9c1bcb0037e160451bb2a751b19bd6dfff6089686589eed659dbd

Contents?: true

Size: 904 Bytes

Versions: 5

Compression:

Stored size: 904 Bytes

Contents

_shellject()
{
  local cur prev opts base save_dir
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev="${COMP_WORDS[COMP_CWORD-1]}"

  case "${prev}" in
    shellject)
      COMPREPLY=($(compgen -W "load save setup --help --version" -- ${cur}))
      return 0
      ;;
    save)
      #  Use default filename completion (when combined with -o default below)
      COMPREPLY=()
      return 0
      ;;
    load)
      #
      #  Shelljections we know about, removing save dir as a  prefix.
      #
      save_dir=${SHELLJECT_SAVE_DIR:- $(ls -d ~/.shellject/shelljections)}
      # Escape save_dir for regex
      local prefix=$(echo ${save_dir}/ | sed -e 's/[\/&]/\\&/g')
      local shelljections=$(find ${save_dir} -type f| sed -e "s/${prefix}\(.*\)/\1/")
      COMPREPLY=( $(compgen -W "${shelljections}" -- ${cur}) )
      return 0
      ;;
  esac

}
complete -F _shellject -o default shellject

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shellject-1.0.2 bash/shellject_completion.sh
shellject-1.0.1 bash/shellject_completion.sh
shellject-0.3.0 bash/shellject_completion.sh
shellject-0.2.0 bash/shellject_completion.sh
shellject-0.1.0 bash/shellject_completion.sh