Merge branch 'main' into ws

This commit is contained in:
Ajeet D'Souza 2021-10-08 20:00:18 +05:30 committed by GitHub
commit 7b8b6bbdb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 4 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. - 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 ## [0.7.5] - 2020-09-09
### Added ### Added

View File

@ -328,6 +328,7 @@ They must be set before `zoxide init` is called.
| [ranger] | File manager | [ranger-zoxide] | | [ranger] | File manager | [ranger-zoxide] |
| [telescope.nvim] | Fuzzy finder for Neovim | [telescope-zoxide] | | [telescope.nvim] | Fuzzy finder for Neovim | [telescope-zoxide] |
| [vim] | Text editor | [zoxide.vim] | | [vim] | Text editor | [zoxide.vim] |
| [xplr] | File manager | [zoxide.xplr] |
| [xxh] | Transports shell configuration over SSH | [xxh-plugin-prerun-zoxide] | | [xxh] | Transports shell configuration over SSH | [xxh-plugin-prerun-zoxide] |
| [zsh-autocomplete] | Realtime completions for zsh | Supported by default | | [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 [vim]: https://github.com/vim/vim
[void linux packages]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zoxide [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" [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-plugin-prerun-zoxide]: https://github.com/xxh/xxh-plugin-prerun-zoxide
[xxh]: https://github.com/xxh/xxh [xxh]: https://github.com/xxh/xxh
[zoxide.el]: https://gitlab.com/Vonfry/zoxide.el [zoxide.el]: https://gitlab.com/Vonfry/zoxide.el
[zoxide.vim]: https://github.com/nanotee/zoxide.vim [zoxide.vim]: https://github.com/nanotee/zoxide.vim
[zoxide.xplr]: https://github.com/sayanarijit/zoxide.xplr
[zsh-autocomplete]: https://github.com/marlonrichert/zsh-autocomplete [zsh-autocomplete]: https://github.com/marlonrichert/zsh-autocomplete

View File

@ -8,7 +8,7 @@ import os
import os.path import os.path
import subprocess import subprocess
import sys 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.dirstack # type: ignore # pylint: disable=import-error
import xonsh.environ # 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 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: def __zoxide_pwd() -> str:
"""pwd based on the value of _ZO_RESOLVE_SYMLINKS.""" """pwd based on the value of _ZO_RESOLVE_SYMLINKS."""
{%- if resolve_symlinks %} {%- if resolve_symlinks %}
pwd = os.getcwd() pwd = os.getcwd()
{%- else %} {%- else %}
pwd = builtins.__xonsh__.env.get("PWD") # type: ignore # pylint:disable=no-member pwd = __zoxide_env().get("PWD")
if pwd is None: if pwd is None:
raise Exception("$PWD not found") raise Exception("$PWD not found")
{%- endif %} {%- endif %}
@ -93,7 +98,11 @@ if "__zoxide_hook" not in globals():
"""Hook to add new entries to the database.""" """Hook to add new entries to the database."""
pwd = __zoxide_pwd() pwd = __zoxide_pwd()
zoxide = __zoxide_bin() zoxide = __zoxide_bin()
subprocess.run([zoxide, "add", "--", pwd], check=False) subprocess.run(
[zoxide, "add", "--", pwd],
check=False,
env=__zoxide_env(),
)
{% endif -%} {% endif -%}
@ -119,6 +128,7 @@ def __zoxide_z(args: List[str]):
cmd = subprocess.run( cmd = subprocess.run(
[zoxide, "query", "--exclude", __zoxide_pwd(), "--"] + args, [zoxide, "query", "--exclude", __zoxide_pwd(), "--"] + args,
check=True, check=True,
env=__zoxide_env(),
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
) )
except subprocess.CalledProcessError as exc: except subprocess.CalledProcessError as exc:
@ -128,12 +138,16 @@ def __zoxide_z(args: List[str]):
__zoxide_cd(result) __zoxide_cd(result)
@__zoxide_errhandler
def __zoxide_zi(args: List[str]): def __zoxide_zi(args: List[str]):
"""Jump to a directory using interactive search.""" """Jump to a directory using interactive search."""
try: try:
zoxide = __zoxide_bin() zoxide = __zoxide_bin()
cmd = subprocess.run( 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: except subprocess.CalledProcessError as exc:
raise ZoxideSilentException() from exc raise ZoxideSilentException() from exc