Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Activate Bash/ZSH completion #8

Closed
arredond opened this issue Dec 12, 2018 · 1 comment
Closed

Activate Bash/ZSH completion #8

arredond opened this issue Dec 12, 2018 · 1 comment

Comments

@arredond
Copy link
Contributor

Click has built-in support for simple Bash/ZSH completion of subcommands and arguments.

Activation is as simple as adding a couple of lines to .bashrc or .zshrc. In this case, one for each program:

eval "$(_CARTO_BASH_COMPLETE=source carto_bash)"
eval "$(_CARTO_DATASET_COMPLETE=source carto_dataset)"
eval "$(_CARTO_ENV_COMPLETE=source carto_env)"
eval "$(_CARTO_SQL_COMPLETE=source carto_sql)"

Some notes:

  • .bashrc vs .bash_profile: Click needs those lines to be placed explicitly in .bashrc (used for interactive login shells), not .bash_profile. Some MAC users may only have .bash_profile (because MacOS always runs .bash_profile for new terminal windows) so .bashrc should be created if it does not exist.

  • zsh completion: Click 6.x.x does not include ZSH completion in its docs (the latest stable release, 7.x, does, but carto-cli is currently running version 6.7). However, it works just fine, with a small caveat: the same line must be placed in .zshrc as in .bashrc, which uses source instead of source_zsh (at least on MacOS).

  • Shell activation time: As stated in the Click docs, in order for this to work each shell has to invoke each application on startup, which can cause slowdowns (not that I've seen since all these applications are pretty lightweight). Anyhow, the option of including an Activation Script and then calling that from .bashrc/.zshrc is also feasible.

Activating this simple feature seems like pretty low-hanging fruit and I think that current and future users would appreciate it considerably, given the high amount of sub-commands and arguments for each application. I'd be happy to help with this if needed!

@jsanz
Copy link
Owner

jsanz commented Dec 14, 2018

Thanks @arredond I've tried on bash and works very nicely!! On zsh is not working but I think it's worth (and healthy) to update to click 7 so I'll try first that one and update the docs conveniently to help users to get this very convenient feature!

@jsanz jsanz mentioned this issue Dec 14, 2018
@jsanz jsanz closed this as completed Jan 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants