[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can parallel have any shell completions?
From: |
Ole Tange |
Subject: |
Re: Can parallel have any shell completions? |
Date: |
Mon, 30 May 2022 22:27:20 +0200 |
On Sun, May 15, 2022 at 6:29 PM Wu Zhenyu <wuzy01@qq.com> wrote:>
> I found in man, there provide a zsh script:
>
> ```
> --shell-completion shell (alpha testing)
> Generate shell completion code for interactive shells.
>
> Supported shells: bash zsh.
>
> Use auto as shell to automatically detect running shell.
>
> Activate the completion code with:
>
> zsh% eval "$(parallel --shell-completion auto)"
> bash$ eval "$(parallel --shell-completion auto)"
>
> Or put this `/usr/share/zsh/site-functions/_parallel`, then
> `compinit` to generate `~/.zcompdump`:
>
> #compdef parallel
>
> (( $+functions[_comp_parallel] )) ||
> eval "$(parallel --shell-completion auto)" &&
> _comp_parallel
> ```
>
> When we package parallel, we should install the completion script for user to
> provide an out-of-box feeling. As an example of github-cli, this is the
> method them did it:
>
> ```
> cat <<-EOF >./postinst
> #!/usr/bin/sh
> mkdir -p /usr/share/bash-completion/completions
> mkdir -p /usr/share/zsh/site-functions
> mkdir -p /usr/share/fish/vendor_completions.d
> gh completion -s bash >
> /usr/share/bash-completion/completions/gh.bash
> gh completion -s zsh > /usr/share/zsh/site-functions/_gh
> gh completion -s fish >
> /usr/share/fish/vendor_completions.d/gh.fish
> EOF
>
> cat <<-EOF >./prerm
> #!/usr/bin/sh
> rm -f /usr/share/bash-completion/completions/gh.bash
> rm -f /usr/share/zsh/site-functions/_gh
> rm -f /usr/share/fish/vendor_completions.d/gh.fish
> EOF
> ```
>
> For parallel, `parallel --shell-completion bash >
> /usr/share/bash-completion/completions/parallel` can work.
> However, for zsh, it cannot. So how about provide a target named
> `install-zsh-completion` to install
>
> ```zsh
> #compdef parallel
>
> (( $+functions[_comp_parallel] )) ||
> eval "$(parallel --shell-completion auto)" &&
> _comp_parallel
> ```
>
> to `/usr/share/zsh/site-functions/_parallel`? Then let it become a `.PHONY`
> dependence of `install`? It can help downstream to package parallel. Thanks!
I have made it part of `make install` in the git version.
/Ole
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Can parallel have any shell completions?,
Ole Tange <=