Opened 6 years ago

Last modified 6 years ago

#56963 new enhancement

New keywords for bash/zsh tab-completion

Reported by: newtonne Owned by:
Priority: Normal Milestone:
Component: base Version:
Keywords: Cc:
Port:

Description

I see a lot of the same patterns used in Portfiles to install bash/zsh tab-completion. Would it not be better to have a keyword that could perform this functionality so that you just have to specify where the items are within the package. For example, something like:

bash_completion ${worksrcpath}/scripts/shell_completions/bash/borg
zsh_completion ${worksrcpath}/scripts/shell_completions/zsh/_borg

Instead of:

post-destroot {
    set bash_compl_path ${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${bash_compl_path}
    xinstall -m 0644 ${worksrcpath}/scripts/shell_completions/bash/borg \
        ${destroot}${bash_compl_path}
    
    set zsh_compl_path ${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}${zsh_compl_path}
    xinstall -m 0644 ${worksrcpath}/scripts/shell_completions/zsh/_borg \
        ${destroot}${zsh_compl_path}
}

For bash completions, there is the complication of whether the file should be installed to ${prefix}/share/bash-completion/completions/ or ${prefix}/etc/bash_completion.d/, but this could be solved by using a bash_completion_compat keyword for the latter case.

On the rare occasions where setting this up is more involved, the longer method could still be used.

Change History (4)

comment:1 Changed 6 years ago by mf2k (Frank Schima)

How many ports are doing this now? Do you have a list?

comment:2 Changed 6 years ago by newtonne

Hi Frank,

Some rudimentary grepping suggests the following ports install bash completion:

$ ack -l "bash-completion|bash_completion" /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports | grep Portfile | sort | rev | cut -d/ -f2-3 | rev
archivers/unar
devel/bazel
devel/bzr
devel/cargo
devel/docker-machine
devel/docker
devel/git-cola
devel/git-flow-bash-completion
devel/git
devel/google-cloud-sdk
devel/gws
devel/hub
devel/mercurial
devel/ninja
devel/npm2
devel/npm3
devel/npm4
devel/npm5
devel/npm6
devel/redo
devel/subversion
devel/zanata-cli
gis/gdal
java/spring-boot-cli
lang/crystal
net/mosh
net/wireguard-tools
office/task
office/todotxt
python/py-django
python/py-django2
ruby/rbenv
science/plumed
security/pass
sysutils/bash-completion
sysutils/fd
sysutils/libvirt
sysutils/tarsnap
textproc/ripgrep
textproc/the_silver_searcher
www/blazeblogger
www/hugo

And these install zsh completion:

$ ack -l "site-functions" /opt/local/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports | grep Portfile | sort | rev | cut -d/ -f2-3 | rev
devel/bazel
devel/cargo
devel/docker
devel/gws
devel/hub
devel/mercurial
lang/crystal
office/task
ruby/rbenv
sysutils/autojump
sysutils/fd
sysutils/zsh-completions
textproc/ripgrep

I'm now thinking that something similar could also be done for documentation/man pages too, which affects a lot more ports.

Instead of:

set destdocdir ${destroot}${prefix}/share/doc/${name}
xinstall -m 755 -d ${destdocdir}
copy ${worksrcpath}/license ${worksrcpath}/readme ${destdocdir}

You could have something like:

documentation ${worksrcpath}/license ${worksrcpath}/readme

comment:3 Changed 6 years ago by mf2k (Frank Schima)

Thanks. The documentation shortcut sounds like a good idea too. But please open a new ticket for that. No need to have this bogged down with scope creep.

comment:4 Changed 6 years ago by newtonne

Agreed. Just raised #57011 for the documentation shortcut.

Note: See TracTickets for help on using tickets.