diff --git a/README.md b/README.md index 0f2141221..aa985cd47 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,22 @@ pip install --upgrade nf-core Please refer to the respective documentation for further details to manage packages, as for example [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#updating-packages) or [pip](https://packaging.python.org/en/latest/tutorials/installing-packages/#upgrading-packages). +### Activate shell completions for nf-core/tools + +Auto-completion for the `nf-core` command is available for bash, zsh and fish. To activate it, add the following lines to the respective shell config files. +shell | shell config file | command +--- | --- | --- +bash | ~/.bashrc | `eval "$(_NF_CORE_COMPLETE=bash_source nf-core)"` +Zsh | ~/.zshrc | `eval "$(_NF_CORE_COMPLETE=zsh_source nf-core)"` +fish | ~/.config/fish/completions/nf-core.fish | `eval (env _NF_CORE_COMPLETE=fish_source nf-core)` + +After a restart of the shell session you should have auto-completion for the `nf-core` command and all its sub-commands and options. + +> **NB:** The added line will run the command `nf-core` (which will also slow down startup time of your shell). You should therefore either have the nf-core/tools installed globally. +> You can also wrap it inside `if type nf-core > /dev/null; then ` \ `fi` for bash and zsh or `if command -v nf-core &> /dev/null eval (env _NF_CORE_COMPLETE=fish_source nf-core) end` for fish. You need to then source the config in your environment for the completions to be activated. + +> **NB:** If you see the error `command not found compdef` , be sure that your config file contains the line `autoload -Uz compinit && compinit` before the eval line. + ## Listing pipelines The command `nf-core list` shows all available nf-core pipelines along with their latest version, when that was published and how recently the pipeline code was pulled to your local system (if at all). diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 47c6e9936..be44620f3 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -79,27 +79,28 @@ def run_nf_core(): - # Print nf-core header - stderr.print(f"\n[green]{' ' * 42},--.[grey39]/[green],-.", highlight=False) - stderr.print("[blue] ___ __ __ __ ___ [green]/,-._.--~\\", highlight=False) - stderr.print(r"[blue] |\ | |__ __ / ` / \ |__) |__ [yellow] } {", highlight=False) - stderr.print(r"[blue] | \| | \__, \__/ | \ |___ [green]\`-._,-`-,", highlight=False) - stderr.print("[green] `._,._,'\n", highlight=False) - stderr.print( - f"[grey39] nf-core/tools version {nf_core.__version__} - [link=https://nf-co.re]https://nf-co.re[/]", - highlight=False, - ) - try: - is_outdated, _, remote_vers = nf_core.utils.check_if_outdated() - if is_outdated: - stderr.print( - f"[bold bright_yellow] There is a new version of nf-core/tools available! ({remote_vers})", - highlight=False, - ) - except Exception as e: - log.debug(f"Could not check latest version: {e}") - stderr.print("\n") - + # print nf-core header if environment variable is not set + if os.environ.get("_NF_CORE_COMPLETE") is None: + # Print nf-core header + stderr.print(f"\n[green]{' ' * 42},--.[grey39]/[green],-.", highlight=False) + stderr.print("[blue] ___ __ __ __ ___ [green]/,-._.--~\\", highlight=False) + stderr.print(r"[blue] |\ | |__ __ / ` / \ |__) |__ [yellow] } {", highlight=False) + stderr.print(r"[blue] | \| | \__, \__/ | \ |___ [green]\`-._,-`-,", highlight=False) + stderr.print("[green] `._,._,'\n", highlight=False) + stderr.print( + f"[grey39] nf-core/tools version {nf_core.__version__} - [link=https://nf-co.re]https://nf-co.re[/]", + highlight=False, + ) + try: + is_outdated, _, remote_vers = nf_core.utils.check_if_outdated() + if is_outdated: + stderr.print( + f"[bold bright_yellow] There is a new version of nf-core/tools available! ({remote_vers})", + highlight=False, + ) + except Exception as e: + log.debug(f"Could not check latest version: {e}") + stderr.print("\n") # Launch the click cli nf_core_cli(auto_envvar_prefix="NFCORE")