repo_description: A smarter cd command. Supports all major shells.
repo_topics: autojump bash cli command-line command-line-tool elvish fasd fish fish-shell fzf hacktoberfest jump nushell powershell rust shell xonsh xontrib z zsh
code: #[path = "src/cmd/cmd.rs"]
  mod cmd;
  
  use std::{env, io};
  
  use clap::CommandFactory as _;
  use clap_complete::shells::{Bash, Elvish, Fish, PowerShell, Zsh};
  use clap_complete_fig::Fig;
  use clap_complete_nushell::Nushell;
  use cmd::Cmd;
  
  fn main() -> io::Result<()> {
      // Since we are generating completions in the package directory, we need to
      // set this so that Cargo doesn't rebuild every time.
      println!("cargo:rerun-if-changed=build.rs");
      println!("cargo:rerun-if-changed=src/");
      println!("cargo:rerun-if-changed=templates/");
      println!("cargo:rerun-if-changed=tests/");
      generate_completions()
  }
  
  fn generate_completions() -> io::Result<()> {
      const BIN_NAME: &str = env!("CARGO_PKG_NAME");
      const OUT_DIR: &str = "contrib/completions";
      let cmd = &mut Cmd::command();
  
      clap_complete::generate_to(Bash, cmd, BIN_NAME, OUT_DIR)?;
      clap_complete::generate_to(Elvish, cmd, BIN_NAME, OUT_DIR)?;
      clap_complete::generate_to(Fig, cmd, BIN_NAME, OUT_DIR)?;
      clap_complete::generate_to(Fish, cmd, BIN_NAME, OUT_DIR)?;
      clap_complete::generate_to(Nushell, cmd, BIN_NAME, OUT_DIR)?;
      clap_complete::generate_to(PowerShell, cmd, BIN_NAME, OUT_DIR)?;
      clap_complete::generate_to(Zsh, cmd, BIN_NAME, OUT_DIR)?;
  
      Ok(())
  }
  