gratools shell_completion๏ƒ

Boost your productivity with Tab-completion for GraTools commands and options.

โšก Why use Shell Completion?

Shell completion allows you to auto-complete command names, options, and even file paths by simply pressing the Tab key. It prevents typos, saves time, and helps you discover available options without constantly checking the help menu.

Options๏ƒ

๐Ÿ› ๏ธ View Command Line Options
$ gratools shell_completion
Welcome to GraTools version: '1.1.0.dev7'
@author: GraTools team's
        ____                 __________               ____          
      6MMMMMb/               MMMMMMMMMM               `MM          
     8P    YM               /   MM     \               MM          
    6M      Y ___  __    ___    MM   _____     _____   MM   ____   
    MM        `MM 6MM  6MMMMb   MM  6MMMMMb   6MMMMMb  MM  6MMMMb\ 
    MM         MM69 " 8M'  `Mb  MM 6M'   `Mb 6M'   `Mb MM MM'    ` 
    MM     ___ MM'        ,oMM  MM MM     MM MM     MM MM YM.      
    MM     `M' MM     ,6MM9'MM  MM MM     MM MM     MM MM  YMMMMb  
    YM      M  MM     MM'   MM  MM MM     MM MM     MM MM      `Mb 
     8b    d9  MM     MM.  ,MM  MM YM.   ,M9 YM.   ,M9 MM L    ,MM 
      YMMMMM9  _MM_   `YMMM9'Yb_MM_ YMMMMM9   YMMMMM9 _MM_MYMMMM9 
        \                                    /                /
        /''A''\          /''''''\           /     /''''A'''''\
  ...GC|       |..ATG...C...CG...T....TAG..'..GC.|            |...
        \..C../      \.............../            \...TATA.../
 
Please cite our gitlab: https://forge.ird.fr/diade/gratools.git\

Usage: gratools shell_completion [OPTIONS]

  Generates shell completion scripts for GraTools. This enables autocompletion
  for commands, options, and arguments in your terminal, making it easier and
  faster to use the GraTools CLI.
  
  Supported shells: Bash, Zsh, Fish.
  
  After generating the script, you'll need to source it or place it in the
  appropriate directory for your shell to activate autocompletion. Instructions
  will be provided upon script generation.
  
  For more details, see the full documentation:
  https://gratools.readthedocs.io/en/latest/commands/shell_completion.html

Options:
  --shell [bash|zsh|fish]
     Specify your shell type (bash, zsh, or fish) to generate the appropriate
     completion script.  [required]

  --output-file PATH
     Specify the full path (including filename) to save the generated completion
     script. If not provided, defaults to 'gratools-completion.<shell>' in the
     current directory.

  -h, --help
     Show this message and exit.

๐Ÿš€ Setup Instructions๏ƒ

Follow these three steps to enable completion in your terminal environment.

1๏ธโƒฃ Generate

Create the script for your specific shell (Bash or Zsh).

2๏ธโƒฃ Configure

Tell your shell to load this script every time it starts.

3๏ธโƒฃ Reload

Apply the changes to your current session.

Step 1: Generate the Script๏ƒ

Run the command and specify your shell. We recommend saving it in your home directory.

$ gratools shell_completion --shell bash --output ~

# This creates: ~/gratools-completion.bash

Step 2: Configure your Shell๏ƒ

Add the loading logic to your shell configuration file. Choose your shell below:

Append these lines to your ~/.bashrc (or ~/.bash_profile on macOS):

# Add completion for gratools
if [ -f "$HOME/gratools-completion.bash" ]; then
    . "$HOME/gratools-completion.bash"
fi

Append these lines to your ~/.zshrc:

# Add completion for gratools
if [ -f "$HOME/gratools-completion.zsh" ]; then
    source "$HOME/gratools-completion.zsh"
fi
โš ๏ธ Important

Ensure the path in the script matches the actual location where you saved the file in Step 1.

Step 3: Reload Configuration๏ƒ

Apply the changes immediately by โ€œsourcingโ€ your config file:

source ~/.bashrc
source ~/.zshrc

๐ŸŽฎ How to Use it๏ƒ

Once configured, try these โ€œmagicโ€ Tab sequences:

Type gratools list_ + Tab

โŒจ๏ธ Commands
$ gratools list_
list_chr      list_samples

Type -- + Tab

๐Ÿ› ๏ธ Options
$ gratools get_fasta --
--all-samples   --num-threads
--chrom-query   --sample-query

Type a path + Tab

๐Ÿ“ Values
$ gratools stats --gfa ./data-g
# Completes to:
$ gratools stats --gfa ./data-gratools/
๐Ÿ’ก Pro Tip

If you are using Zsh with a framework like Oh My Zsh, make sure compinit is initialized in your .zshrc before sourcing the GraTools completion script for the best experience.

๐Ÿ“‘ Quick Links