From 9b056fb58cbd7fb6d121d460e3929ac9c835826f Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Thu, 28 May 2020 05:15:06 +0530 Subject: [PATCH] Removed help menus for `z` and `zri` functions --- CHANGELOG.md | 4 ++++ src/config.rs | 3 ++- src/subcommand/init/shell/fish.rs | 22 +++++----------------- src/subcommand/init/shell/posix.rs | 14 ++++---------- src/subcommand/init/shell/powershell.rs | 10 ++++------ 5 files changed, 19 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aefc9e0..370aeba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `zri` is now a shell function. +### Removed + +- Help menus for `z` and `zri`. + ## [0.4.1] - 2020-05-25 ### Added diff --git a/src/config.rs b/src/config.rs index ec3affd..790498e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,7 +20,8 @@ pub fn zo_data_dir() -> Result { // This will fail when `data_dir` points to a file or a broken symlink, but // will no-op on a valid symlink (to a directory), or an actual directory. - fs::create_dir_all(&data_dir).context("could not create data directory")?; + fs::create_dir_all(&data_dir) + .with_context(|| format!("could not create data directory: {}", data_dir.display()))?; Ok(data_dir) } diff --git a/src/subcommand/init/shell/fish.rs b/src/subcommand/init/shell/fish.rs index 5cffe83..730f6d2 100644 --- a/src/subcommand/init/shell/fish.rs +++ b/src/subcommand/init/shell/fish.rs @@ -32,23 +32,11 @@ function {} if test $argc -eq 0 _z_cd $HOME - or return $status - - else if test $argc -eq 1 -a $argv[1] = '-' + else if begin; test $argc -eq 1; and test $argv[1] = '-'; end _z_cd - - or return $status - else - # FIXME: use string-collect from fish 3.1.0 once it has wider adoption - set -l IFS '' - set -l _zoxide_result (zoxide query $argv) - - if test -d $_zoxide_result; and string length -q -- $_zoxide_result - _z_cd $_zoxide_result - or return $status - else if test -n "$_zoxide_result" - echo $_zoxide_result - end + set -l _zoxide_result (zoxide query -- $argv) + and _z_cd $_zoxide_result end end "#, @@ -68,8 +56,8 @@ abbr -a {0}qi 'zoxide query -i' abbr -a {0}r 'zoxide remove' function {0}ri - set result (zoxide query -i $argv) - and zoxide remove $result + set -l _zoxide_result (zoxide query -i -- $argv) + and zoxide remove $_zoxide_result end "#, cmd diff --git a/src/subcommand/init/shell/posix.rs b/src/subcommand/init/shell/posix.rs index 16abfef..d052835 100644 --- a/src/subcommand/init/shell/posix.rs +++ b/src/subcommand/init/shell/posix.rs @@ -28,22 +28,16 @@ _z_cd() {{ {}() {{ if [ "$#" -eq 0 ]; then - _z_cd ~ || return "$?" + _z_cd ~ elif [ "$#" -eq 1 ] && [ "$1" = '-' ]; then if [ -n "$OLDPWD" ]; then - _z_cd "$OLDPWD" || return "$?" + _z_cd "$OLDPWD" else echo 'zoxide: $OLDPWD is not set' return 1 fi else - _zoxide_result="$(zoxide query "$@")" || return "$?" - if [ -d "$_zoxide_result" ]; then - _z_cd "$_zoxide_result" || return "$?" - elif [ -n "$_zoxide_result" ]; then - echo "$_zoxide_result" - fi - unset _zoxide_result + _zoxide_result="$(zoxide query -- "$@")" && _z_cd "$_zoxide_result" fi }} "#, @@ -63,7 +57,7 @@ alias {0}qi='zoxide query -i' alias {0}r='zoxide remove' {0}ri() {{ - result=$(zoxide query -i "$@") && zoxide remove "$result" + _zoxide_result="$(zoxide query -i -- "$@")" && zoxide remove "$_zoxide_result" }} "#, cmd diff --git a/src/subcommand/init/shell/powershell.rs b/src/subcommand/init/shell/powershell.rs index 2c7ac2a..ac220d4 100644 --- a/src/subcommand/init/shell/powershell.rs +++ b/src/subcommand/init/shell/powershell.rs @@ -31,11 +31,9 @@ function {} {{ z_cd - }} else {{ - $_zoxide_result = zoxide query @args - if ($LASTEXITCODE -eq 0 -and $_zoxide_result -is [string] -and (Test-Path $_zoxide_result)) {{ + $_zoxide_result = zoxide query -- @args + if ($LASTEXITCODE -eq 0) {{ z_cd $_zoxide_result - }} else {{ - $_zoxide_result }} }} }} @@ -56,9 +54,9 @@ function {0}qi {{ zoxide query -i @args }} function {0}r {{ zoxide remove @args }} function {0}ri {{ - $result = zoxide query -i @args + $_zoxide_result = zoxide query -i -- @args if ($LASTEXITCODE -eq 0) {{ - zoxide remove $result + zoxide remove $_zoxide_result }} }} "#,