From 5ffb52fa5feb311ce9ae834752c2fefa85549f9f Mon Sep 17 00:00:00 2001 From: Ritesh Raj Sarraf Date: Thu, 3 Oct 2024 19:53:17 +0530 Subject: [PATCH] Use $XONSHRC environment variable to ascertain files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because the assumption that those hard-coded paths are the only paths a user may have feels wrong. Also, Because pathlib.Path wasn't resolving ~ to a proper absolute path. ``` ♄ 19:46:51 rrs@priyasi ~ [1] ☸ cs00114-we-01-aks @ from pathlib import Path ♒︎ 19:46:56 rrs@priyasi ~ ☸ cs00114-we-01-ak s @ Path("~/.xonshrc") PosixPath('~/.xonshrc') ⛢ 19:47:16 rrs@priyasi ~ ☸ cs00114-we-01-aks @ Path("~/.xonshrc").is_file() False ♅ 19:47:22 rrs@priyasi ~ ☸ cs00114-we-01-aks @ Path("/home/rrs/.xonshrc").is_file() True ॐ 19:47:30 rrs@priyasi ~ ☸ cs00114-we-01-aks @ $XONSHRC ('/etc/xonsh/xonshrc', '/home/rrs/.config/xonsh/rc.xsh', '/home/rrs/.xonshrc') ⛢ 19:48:21 rrs@priyasi ~ ☸ cs00114-we-01-aks @ for file in $XONSHRC: . print(file) . /etc/xonsh/xonshrc /home/rrs/.config/xonsh/rc.xsh /home/rrs/.xonshrc ```` Closes: https://github.com/sbstp/kubie/issues/243 --- src/shell/xonsh.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/shell/xonsh.rs b/src/shell/xonsh.rs index c7509e4b..e9fcd6b0 100644 --- a/src/shell/xonsh.rs +++ b/src/shell/xonsh.rs @@ -18,11 +18,8 @@ pub fn spawn_shell(info: &ShellSpawnInfo) -> Result<()> { # https://xon.sh/xonshrc.html from pathlib import Path -files = [ - "/etc/xonshrc", - "~/.xonshrc", - "~/.config/xonsh/rc.xsh", -] +files = $XONSHRC + for file in files: if Path(file).is_file(): source @(file)