From 34ab8f3f8b502f11ba51dd69af75ee7f4dcf0654 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Wed, 11 Mar 2020 01:23:49 +0530 Subject: [PATCH] Add --no-define-aliases flag to zoxide init --- README.md | 2 ++ src/main.rs | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 69d0b1e..6fa4434 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ If you want the interactive fuzzy selection feature, you will also need to insta ### Step 2: Adding `zoxide` to your shell +By default, `zoxide` defines the `z`, `zi`, `za`, `zq`, and `zr` aliases. If you'd like to go with just the barebones `z`, pass the `--no-define-aliases` flag to `zoxide init`. + #### zsh Add the following line to your `~/.zshrc`: diff --git a/src/main.rs b/src/main.rs index 38c3b09..dc3a617 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,6 +34,8 @@ enum Zoxide { Init { #[structopt(possible_values = &Shell::variants(), case_insensitive = true)] shell: Shell, + #[structopt(long, help = "Prevents zoxide from defining any aliases other than 'z'")] + no_define_aliases: bool, }, #[structopt(about = "Search for a directory")] @@ -92,19 +94,28 @@ pub fn main() -> Result<()> { db.save()?; } - Zoxide::Init { shell } => { + Zoxide::Init { + shell, + no_define_aliases, + } => { match shell { Shell::bash => { println!("{}", INIT_BASH); - println!("{}", INIT_BASH_ALIAS); + if !no_define_aliases { + println!("{}", INIT_BASH_ALIAS); + } } Shell::fish => { println!("{}", INIT_FISH); - println!("{}", INIT_FISH_ALIAS); + if !no_define_aliases { + println!("{}", INIT_FISH_ALIAS); + } } Shell::zsh => { println!("{}", INIT_ZSH); - println!("{}", INIT_ZSH_ALIAS); + if !no_define_aliases { + println!("{}", INIT_ZSH_ALIAS); + } } }; }