Skip to content

Commit

Permalink
Add --no-define-aliases flag to zoxide init
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed Mar 10, 2020
1 parent f0c5e28 commit 34ab8f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
19 changes: 15 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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);
}
}
};
}
Expand Down

0 comments on commit 34ab8f3

Please sign in to comment.