diff --git a/CHANGELOG.md b/CHANGELOG.md index 7afd6e5..598a2c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nushell: upgrade minimum supported version to v0.37.0. +### Fixed + +- Xonsh: error messages in `zi`. +- Xonsh: configuration environment variables not being handled correctly. + ## [0.7.5] - 2020-09-09 ### Added diff --git a/README.md b/README.md index f9e46e4..3c4d0a5 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,7 @@ They must be set before `zoxide init` is called. | [ranger] | File manager | [ranger-zoxide] | | [telescope.nvim] | Fuzzy finder for Neovim | [telescope-zoxide] | | [vim] | Text editor | [zoxide.vim] | +| [xplr] | File manager | [zoxide.xplr] | | [xxh] | Transports shell configuration over SSH | [xxh-plugin-prerun-zoxide] | | [zsh-autocomplete] | Realtime completions for zsh | Supported by default | @@ -375,8 +376,10 @@ They must be set before `zoxide init` is called. [vim]: https://github.com/vim/vim [void linux packages]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zoxide [wiki-env]: https://github.com/ajeetdsouza/zoxide/wiki/HOWTO:-set-environment-variables "HOWTO: set environment variables" +[xplr]: https://github.com/sayanarijit/xplr [xxh-plugin-prerun-zoxide]: https://github.com/xxh/xxh-plugin-prerun-zoxide [xxh]: https://github.com/xxh/xxh [zoxide.el]: https://gitlab.com/Vonfry/zoxide.el [zoxide.vim]: https://github.com/nanotee/zoxide.vim +[zoxide.xplr]: https://github.com/sayanarijit/zoxide.xplr [zsh-autocomplete]: https://github.com/marlonrichert/zsh-autocomplete diff --git a/templates/xonsh.txt b/templates/xonsh.txt index 85292b7..522f2be 100644 --- a/templates/xonsh.txt +++ b/templates/xonsh.txt @@ -8,7 +8,7 @@ import os import os.path import subprocess import sys -from typing import AnyStr, List, Optional +from typing import AnyStr, Dict, List, Optional import xonsh.dirstack # type: ignore # pylint: disable=import-error import xonsh.environ # type: ignore # pylint: disable=import-error @@ -26,12 +26,17 @@ def __zoxide_bin() -> str: return zoxide +def __zoxide_env() -> Dict[str, str]: + """Returns the current environment.""" + return builtins.__xonsh__.env.detype() # type: ignore # pylint:disable=no-member + + def __zoxide_pwd() -> str: """pwd based on the value of _ZO_RESOLVE_SYMLINKS.""" {%- if resolve_symlinks %} pwd = os.getcwd() {%- else %} - pwd = builtins.__xonsh__.env.get("PWD") # type: ignore # pylint:disable=no-member + pwd = __zoxide_env().get("PWD") if pwd is None: raise Exception("$PWD not found") {%- endif %} @@ -93,7 +98,11 @@ if "__zoxide_hook" not in globals(): """Hook to add new entries to the database.""" pwd = __zoxide_pwd() zoxide = __zoxide_bin() - subprocess.run([zoxide, "add", "--", pwd], check=False) + subprocess.run( + [zoxide, "add", "--", pwd], + check=False, + env=__zoxide_env(), + ) {% endif -%} @@ -119,6 +128,7 @@ def __zoxide_z(args: List[str]): cmd = subprocess.run( [zoxide, "query", "--exclude", __zoxide_pwd(), "--"] + args, check=True, + env=__zoxide_env(), stdout=subprocess.PIPE, ) except subprocess.CalledProcessError as exc: @@ -128,12 +138,16 @@ def __zoxide_z(args: List[str]): __zoxide_cd(result) +@__zoxide_errhandler def __zoxide_zi(args: List[str]): """Jump to a directory using interactive search.""" try: zoxide = __zoxide_bin() cmd = subprocess.run( - [zoxide, "query", "-i", "--"] + args, check=True, stdout=subprocess.PIPE + [zoxide, "query", "-i", "--"] + args, + check=True, + env=__zoxide_env(), + stdout=subprocess.PIPE, ) except subprocess.CalledProcessError as exc: raise ZoxideSilentException() from exc