@shutootaki/gwm
Version:
git worktree manager CLI
53 lines (48 loc) • 1.42 kB
JavaScript
/**
* zsh 補完スクリプト生成
*/
/**
* zsh 補完スクリプトを生成
* @param _definition 補完定義(将来の定義駆動生成に備えて予約)
* @returns zsh 補完スクリプト文字列
*/
export function generateZshScript(_definition) {
return `#compdef gwm
# gwm zsh completion script
# Generated by gwm completion
#
# Installation:
# gwm completion install --shell zsh
#
# Manual installation:
# Copy this file to ~/.zsh/completions/_gwm
# Ensure your fpath includes ~/.zsh/completions
# Add the following to your ~/.zshrc (before compinit):
# fpath=(~/.zsh/completions $fpath)
# Then run:
# autoload -Uz compinit && compinit
_gwm() {
local curcontext="$curcontext" state line
typeset -A opt_args
# 現在のワード位置を計算(gwm 自体を除く)
local words_without_cmd=("\${words[@]:1}")
local cword=$((CURRENT - 1))
# gwm completion __complete を呼び出し
local candidates
candidates=$(gwm completion __complete --shell zsh --cword "$cword" -- "\${words_without_cmd[@]}" 2>/dev/null)
if [[ -n "$candidates" ]]; then
local -a completions
while IFS=$'\\t' read -r value desc; do
if [[ -n "$desc" ]]; then
completions+=("\${value}:\${desc}")
else
completions+=("$value")
fi
done <<< "$candidates"
_describe 'gwm' completions
fi
}
_gwm "$@"
`;
}
//# sourceMappingURL=zsh.js.map