Skip to content

Commit

Permalink
Merge pull request #21 from anki-code/patch-2
Browse files Browse the repository at this point in the history
Avoid changing global config
  • Loading branch information
74th authored Aug 23, 2024
2 parents f96ecc0 + c70f379 commit a8e3bec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ This works with python 3.7.0, xonsh 0.8.8 and direnv 2.17.0.
change log
==========

1.6.4
-----
* PR https://github.com/74th/xonsh-direnv/pull/21


1.6.3
-----

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="xonsh-direnv",
version="1.6.3",
version="1.6.4",
license="MIT",
url="https://github.com/74th/xonsh-direnv",
description="direnv support for the xonsh shell",
Expand Down
14 changes: 6 additions & 8 deletions xontrib/direnv.xsh
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import json

# workaround for https://github.com/74th/xonsh-direnv/issues/2
$UPDATE_OS_ENVIRON = True

def __direnv():
r = $(direnv export json)
if r:
lines = json.loads(r)
for k, v in lines.items():
if v is None:
del __xonsh__.env[k]
else:
__xonsh__.env[k] = v
with __xonsh__.env.swap(UPDATE_OS_ENVIRON=True): # workaround for https://github.com/74th/xonsh-direnv/issues/2
for k, v in lines.items():
if v is None:
del __xonsh__.env[k]
else:
__xonsh__.env[k] = v

@events.on_post_rc
def __direnv_post_rc(**kwargs) -> None:
Expand Down

0 comments on commit a8e3bec

Please sign in to comment.