xonsh: Fix error messages (#273)

This commit is contained in:
Ajeet D'Souza 2021-10-05 15:56:04 +05:30 committed by GitHub
parent 917663485f
commit 8ec3a8b6c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 16 deletions

View File

@ -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

24
Cargo.lock generated
View File

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "anyhow"
version = "1.0.43"
version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf"
checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"
[[package]]
name = "arrayvec"
@ -115,9 +115,9 @@ dependencies = [
[[package]]
name = "bstr"
version = "0.2.16"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90682c8d613ad3373e66de8c6411e0ae2ab2571e879d2efbf73558cc66f21279"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"lazy_static",
"memchr",
@ -302,9 +302,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.101"
version = "0.2.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21"
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6"
[[package]]
name = "memchr"
@ -417,9 +417,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
dependencies = [
"proc-macro2",
]
@ -572,9 +572,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.76"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84"
checksum = "a4eac2e6c19f5c3abc0c229bea31ff0b9b091c7b14990e8924b92902a303a0c0"
dependencies = [
"proc-macro2",
"quote",
@ -633,9 +633,9 @@ checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-width"
version = "0.1.8"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "unicode-xid"

View File

@ -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

View File

@ -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