Open cleder opened 1 year ago
We can also add the print-completion-script to the venv activate script. here an example how to do it with invoke
activate script
import os import pathlib import sys import invoke ROOT_DIR = pathlib.Path(__file__).parent @invoke.task def complete(context): """Activate the invoke shell completion.""" shell = pathlib.Path(os.environ.get("SHELL", "")).name completion_script = context.run( f"invoke --print-completion-script {shell}", hide=True, ).stdout with open(".invoke-completion.sh", "w", encoding="UTF-8") as f: f.write(completion_script) venv_activate = pathlib.Path(sys.executable).parent / 'activate' with open(venv_activate, "a", encoding="UTF-8") as f: f.write(f"\n. {ROOT_DIR / '.invoke-completion.sh'}\n")
We can also add the print-completion-script to the venv
activate script
. here an example how to do it with invoke