zshConfiguration top-level property

  1. @visibleForTesting
ShellCompletionConfiguration zshConfiguration
final

Implementation

@visibleForTesting
final zshConfiguration = ShellCompletionConfiguration._(
  shell: SystemShell.zsh,
  shellRCFile: '~/.zshrc',
  sourceLineTemplate: (String scriptPath) {
    return '[[ -f $scriptPath ]] && . $scriptPath || true';
  },
  scriptTemplate: (String rootCommand) {
    // Completion script for zsh.
    //
    // Based on https://github.com/mklabs/tabtab/blob/master/lib/scripts/zsh.sh
    return '''
if type compdef &>/dev/null; then
  _${rootCommand}_completion () {
    local reply
    local si=\$IFS

    IFS=\$'\n' reply=(\$(COMP_CWORD="\$((CURRENT-1))" COMP_LINE="\$BUFFER" COMP_POINT="\$CURSOR" $rootCommand completion -- "\${words[@]}"))
    IFS=\$si

    if [[ -z "\$reply" ]]; then
        _path_files
    else
        _describe 'values' reply
    fi
  }
  compdef _${rootCommand}_completion $rootCommand
fi
''';
  },
);