Add --no-define-aliases flag to zoxide init

This commit is contained in:
Ajeet D'Souza 2020-03-11 01:23:49 +05:30
parent f0c5e28fd7
commit 34ab8f3f8b
2 changed files with 17 additions and 4 deletions

View File

@ -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`:

View File

@ -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);
}
}
};
}