From e0572a4569fff3144b0e11068183508e18b8d1b6 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Sun, 3 May 2020 15:15:40 +0530 Subject: [PATCH] Rename --z-cmd flag to --cmd --- CHANGELOG.md | 2 ++ src/subcommand/init/mod.rs | 7 ++++--- src/subcommand/init/shell/fish.rs | 2 +- src/subcommand/init/shell/posix.rs | 8 ++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3d45e5..efaefbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Canonicalize to regular paths instead of UNC paths on Windows. - `zoxide init` now uses PWD hooks by default for better performance. - `$_ZO_ECHO` now only works when set to `1`. +- Using the `--z-cmd` flag now also renames the associated aliases. +- The `--z-cmd` flag has been renamed to `--cmd`. ### Fixed diff --git a/src/subcommand/init/mod.rs b/src/subcommand/init/mod.rs index 48318a7..7f1001c 100644 --- a/src/subcommand/init/mod.rs +++ b/src/subcommand/init/mod.rs @@ -15,9 +15,10 @@ pub struct Init { #[structopt( long, help = "Changes the name of the 'z' command", + alias = "z-cmd", default_value = "z" )] - z_cmd: String, + cmd: String, #[structopt( long, @@ -48,11 +49,11 @@ impl Init { let mut handle = stdout.lock(); let z = config.z; - writeln!(handle, "{}", z(&self.z_cmd)).unwrap(); + writeln!(handle, "{}", z(&self.cmd)).unwrap(); if !self.no_define_aliases { let alias = config.alias; - writeln!(handle, "{}", alias(&self.z_cmd)).unwrap(); + writeln!(handle, "{}", alias(&self.cmd)).unwrap(); } match self.hook { diff --git a/src/subcommand/init/shell/fish.rs b/src/subcommand/init/shell/fish.rs index 5def0dc..bd4b36f 100644 --- a/src/subcommand/init/shell/fish.rs +++ b/src/subcommand/init/shell/fish.rs @@ -1,4 +1,4 @@ -use super::{ShellConfig, HookConfig}; +use super::{HookConfig, ShellConfig}; use anyhow::Result; diff --git a/src/subcommand/init/shell/posix.rs b/src/subcommand/init/shell/posix.rs index 0cee455..520e964 100644 --- a/src/subcommand/init/shell/posix.rs +++ b/src/subcommand/init/shell/posix.rs @@ -14,7 +14,7 @@ pub const CONFIG: ShellConfig = ShellConfig { }, }; -fn z(z_cmd: &str) -> String { +fn z(cmd: &str) -> String { format!( r#" _z_cd() {{ @@ -45,11 +45,11 @@ _z_cd() {{ fi }} "#, - z_cmd + cmd ) } -fn alias(z_cmd: &str) -> String { +fn alias(cmd: &str) -> String { format!( r#" alias {0}i='{0} -i' @@ -62,7 +62,7 @@ alias {0}qi='zoxide query -i' alias {0}r='zoxide remove' alias {0}ri='zoxide remove -i' "#, - z_cmd + cmd ) }