From 6be3998bb62c199c854d2c7a44e33fe1dfe0a537 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Tue, 24 Aug 2021 02:00:34 +0530 Subject: [PATCH] Fixes for elvish 0.16.0 (#255) --- CHANGELOG.md | 7 +++++++ README.md | 7 +++++-- shell.nix | 2 +- templates/elvish.txt | 22 ++++++++++++++++++---- templates/nushell.txt | 3 ++- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8006fe..898f9cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Elvish: unable to `z` into directories by path. +- Elvish: don't show traceback when `z` or `zi` fails. + ## [0.7.4] - 2020-08-15 ### Fixed diff --git a/README.md b/README.md index 5c372cf..06e6bf2 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,8 @@ Add this to your configuration (usually `~/.elvish/rc.elv`): eval (zoxide init elvish | slurp) ``` +Note that zoxide only supports elvish v0.16.0+. +
@@ -163,7 +165,7 @@ zoxide init fish | source
-nushell v0.33+ +nushell Add this to your configuration (find it by running `config path` in Nushell): @@ -172,7 +174,8 @@ prompt = "__zoxide_hook;__zoxide_prompt" startup = ["zoxide init nushell --hook prompt | save ~/.zoxide.nu", "source ~/.zoxide.nu"] ``` -You can replace `__zoxide_prompt` with a custom prompt. +You can replace `__zoxide_prompt` with a custom prompt. Note that zoxide only +supports Nushell v0.33.0+.
diff --git a/shell.nix b/shell.nix index 69d93bf..25820ec 100644 --- a/shell.nix +++ b/shell.nix @@ -1,7 +1,7 @@ let rust = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/ad311f5bb5c5ef475985f1e0f264e831470a8510.tar.gz"); pkgs = import { overlays = [ rust ]; }; - pkgs-latest = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/1359293549af4f8ca536716d0432f3cdd0afe0c6.tar.gz") {}; + pkgs-latest = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/b4692e4197869c42c46d77e31af7e687e1892f55.tar.gz") {}; pkgs-python = pkgs-latest.python3.withPackages (pkgs: [ pkgs.black pkgs.mypy pkgs.pylint ]); in pkgs.mkShell { diff --git a/templates/elvish.txt b/templates/elvish.txt index 875f16c..4c67b12 100644 --- a/templates/elvish.txt +++ b/templates/elvish.txt @@ -49,17 +49,29 @@ fn __zoxide_z [@rest]{ __zoxide_cd ~ } elif (builtin:eq [-] $rest) { __zoxide_cd (builtin:get-env __zoxide_oldpwd) - } elif (and (builtin:eq (builtin:count $rest) 1) (path:is-dir $rest[0])) { + } elif (and ('builtin:==' (builtin:count $rest) 1) (path:is-dir &follow-symlink=$true $rest[0])) { __zoxide_cd $rest[0] } else { - __zoxide_cd (zoxide query --exclude $pwd -- $@rest) + var path + try { + path = (zoxide query --exclude $pwd -- $@rest) + } except { + } else { + __zoxide_cd $path + } } } edit:add-var __zoxide_z~ $__zoxide_z~ # Jump to a directory using interactive search. fn __zoxide_zi [@rest]{ - __zoxide_cd (zoxide query -i -- $@rest) + var path + try { + path = (zoxide query -i -- $@rest) + } except { + } else { + __zoxide_cd $path + } } edit:add-var __zoxide_zi~ $__zoxide_zi~ @@ -83,4 +95,6 @@ edit:add-var zi~ $__zoxide_zi~ # To initialize zoxide, add this to your configuration (usually # ~/.elvish/rc.elv): # -# eval (zoxide init elvish | slurp) +# eval (zoxide init elvish | slurp) +# +# Note that zoxide only supports elvish v0.16.0+. diff --git a/templates/nushell.txt b/templates/nushell.txt index 4f222a5..7929bfa 100644 --- a/templates/nushell.txt +++ b/templates/nushell.txt @@ -101,4 +101,5 @@ alias {{cmd}}i = __zoxide_zi # prompt = '__zoxide_hook;__zoxide_prompt' # startup = ['zoxide init nushell --hook prompt | save ~/.zoxide.nu', 'source ~/.zoxide.nu'] # -# You can replace __zoxide_prompt with a custom prompt. +# You can replace __zoxide_prompt with a custom prompt. Note that zoxide only +# supports Nushell v0.33.0+.