From f7bbf335cf667423b8f6c272c6ff73be12366f42 Mon Sep 17 00:00:00 2001 From: 1 <1@1.1> Date: Thu, 27 Nov 2025 20:57:31 +0600 Subject: [PATCH 01/10] Add xonsh shell --- src/cli/self_update/env.xsh | 1 + src/cli/self_update/shell.rs | 59 ++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/cli/self_update/env.xsh diff --git a/src/cli/self_update/env.xsh b/src/cli/self_update/env.xsh new file mode 100644 index 0000000000..991f1ebd3a --- /dev/null +++ b/src/cli/self_update/env.xsh @@ -0,0 +1 @@ +$PATH.append(p) if (p := '{cargo_bin}') not in $PATH else None diff --git a/src/cli/self_update/shell.rs b/src/cli/self_update/shell.rs index ea48595790..00fb96ed59 100644 --- a/src/cli/self_update/shell.rs +++ b/src/cli/self_update/shell.rs @@ -69,6 +69,7 @@ fn enumerate_shells() -> Vec { Box::new(Nu), Box::new(Tcsh), Box::new(Pwsh), + Box::new(Xonsh), ] } @@ -445,6 +446,64 @@ impl UnixShell for Pwsh { } } +struct Xonsh; + +impl UnixShell for Xonsh { + fn does_exist(&self, process: &Process) -> bool { + process.var("XONSHRC").is_ok() + || utils::find_cmd(&["xonsh"], process).is_some() + } + + fn rcfiles(&self, process: &Process) -> Vec { + let mut paths = vec![]; + + if let Ok(p) = process.var("XDG_CONFIG_HOME") { + let mut p = PathBuf::from(p); + p.extend(["xonsh", "rc.xsh"]); + paths.push(p); + } + + if let Some(mut p) = process.home_dir() { + p.extend([".config", "xonsh", "rc.xsh"]); + paths.push(p); + } + + if let Some(home) = process.home_dir() { + paths.push(home.join(".xonshrc")); + } + + paths + } + + fn update_rcs(&self, process: &Process) -> Vec { + for f in self.rcfiles(process) { + if f.is_file() { + return vec![f]; + } + } + + match process.home_dir() { + Some(home) => vec![home.join(".xonshrc")], + None => vec![], + } + } + + fn env_script(&self) -> ShellScript { + ShellScript { + name: "env.xsh", + content: include_str!("env.xsh"), + } + } + + fn source_string(&self, process: &Process) -> Result { + Ok(format!( + r#"source "{}/env.xsh""#, + self.cargo_home_str(process)? + )) + } +} + + pub(crate) fn legacy_paths(process: &Process) -> impl Iterator + '_ { let zprofiles = Zsh::zdotdir(process) .into_iter() From ade42adf9d43e8376d9a3b9be7aa4ae909535958 Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Thu, 27 Nov 2025 20:59:55 +0600 Subject: [PATCH 02/10] Fix variable name in path append condition --- src/cli/self_update/env.xsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/self_update/env.xsh b/src/cli/self_update/env.xsh index 991f1ebd3a..469274c80f 100644 --- a/src/cli/self_update/env.xsh +++ b/src/cli/self_update/env.xsh @@ -1 +1 @@ -$PATH.append(p) if (p := '{cargo_bin}') not in $PATH else None +$PATH.append(_cargo_bin) if (_cargo_bin := '{cargo_bin}') not in $PATH else None From 1c71d510970d203b92a86c931ca6368d1dd8561b Mon Sep 17 00:00:00 2001 From: 1 <1@1.1> Date: Thu, 27 Nov 2025 21:02:52 +0600 Subject: [PATCH 03/10] Fix formatting --- src/cli/self_update/shell.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cli/self_update/shell.rs b/src/cli/self_update/shell.rs index 00fb96ed59..f130df3dd8 100644 --- a/src/cli/self_update/shell.rs +++ b/src/cli/self_update/shell.rs @@ -450,8 +450,7 @@ struct Xonsh; impl UnixShell for Xonsh { fn does_exist(&self, process: &Process) -> bool { - process.var("XONSHRC").is_ok() - || utils::find_cmd(&["xonsh"], process).is_some() + process.var("XONSHRC").is_ok() || utils::find_cmd(&["xonsh"], process).is_some() } fn rcfiles(&self, process: &Process) -> Vec { From d4063727033f1c67b1a5939341d10da38c047057 Mon Sep 17 00:00:00 2001 From: 1 <1@1.1> Date: Thu, 27 Nov 2025 21:04:17 +0600 Subject: [PATCH 04/10] Fix formatting --- src/cli/self_update/shell.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cli/self_update/shell.rs b/src/cli/self_update/shell.rs index f130df3dd8..b24cca2881 100644 --- a/src/cli/self_update/shell.rs +++ b/src/cli/self_update/shell.rs @@ -502,7 +502,6 @@ impl UnixShell for Xonsh { } } - pub(crate) fn legacy_paths(process: &Process) -> impl Iterator + '_ { let zprofiles = Zsh::zdotdir(process) .into_iter() From 486828b76d800781bbdf0bc8294c41e0a154de08 Mon Sep 17 00:00:00 2001 From: 1 <1@1.1> Date: Thu, 27 Nov 2025 21:07:08 +0600 Subject: [PATCH 05/10] Added source command --- src/cli/self_update.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index 2e70b187d9..7f09e5050b 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -457,6 +457,7 @@ This is usually done by running one of the following (note the leading DOT): source $"{cargo_home_nushell}/env.nu" # For nushell source "{cargo_home}/env.tcsh" # For tcsh . "{cargo_home}/env.ps1" # For pwsh + source "{cargo_home}/env.xsh" # For xonsh "# }; } From 8b5c259f085545cdeb75c33b8914ddf639cb182b Mon Sep 17 00:00:00 2001 From: 1 <1@1.1> Date: Thu, 27 Nov 2025 21:13:56 +0600 Subject: [PATCH 06/10] Completion in xonsh --- src/cli/help.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cli/help.rs b/src/cli/help.rs index 802d0de174..dd0d05bc16 100644 --- a/src/cli/help.rs +++ b/src/cli/help.rs @@ -261,6 +261,10 @@ pub(crate) fn completions_help() -> String { This installs the completion script. You may have to log out and log back in to your shell session for the changes to take effect. + {SUBHEADER}Xonsh:{SUBHEADER:#} + + In Xonsh you can reuse Fish completion by installing `xontrib-fish-completer`. + {SUBHEADER}Zsh:{SUBHEADER:#} ZSH completions are commonly stored in any directory listed in From ccea87165aa282337f53a43f1700ed784baa6e40 Mon Sep 17 00:00:00 2001 From: 1 <1@1.1> Date: Thu, 27 Nov 2025 21:17:40 +0600 Subject: [PATCH 07/10] Completion in xonsh --- doc/user-guide/src/installation/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/user-guide/src/installation/index.md b/doc/user-guide/src/installation/index.md index d97dd3f7b0..48a25d780e 100644 --- a/doc/user-guide/src/installation/index.md +++ b/doc/user-guide/src/installation/index.md @@ -100,3 +100,5 @@ For `zsh`, you must then add the following line in your `~/.zshrc` before ```zsh fpath+=~/.zfunc ``` + +For Xonsh you can reuse Fish completer by installation [xontrib-fish-completer](https://github.com/xonsh/xontrib-fish-completer). \ No newline at end of file From 6fae2ed1d43edfb5b9e8d6bddd85414888769f50 Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Thu, 27 Nov 2025 21:19:35 +0600 Subject: [PATCH 08/10] Update Xonsh completion installation instructions --- doc/user-guide/src/installation/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user-guide/src/installation/index.md b/doc/user-guide/src/installation/index.md index 48a25d780e..8730088541 100644 --- a/doc/user-guide/src/installation/index.md +++ b/doc/user-guide/src/installation/index.md @@ -101,4 +101,4 @@ For `zsh`, you must then add the following line in your `~/.zshrc` before fpath+=~/.zfunc ``` -For Xonsh you can reuse Fish completer by installation [xontrib-fish-completer](https://github.com/xonsh/xontrib-fish-completer). \ No newline at end of file +In Xonsh you can reuse Fish completion by installing [xontrib-fish-completer](https://github.com/xonsh/xontrib-fish-completer). From 9a385584cf0bca317088ce3ac52ea0770e7a9753 Mon Sep 17 00:00:00 2001 From: 1 <1@1.1> Date: Thu, 27 Nov 2025 22:05:38 +0600 Subject: [PATCH 09/10] Update svg --- ..._completions_cmd_help_flag.stdout.term.svg | 138 +++++++++--------- 1 file changed, 73 insertions(+), 65 deletions(-) diff --git a/tests/suite/cli_rustup_ui/rustup_completions_cmd_help_flag.stdout.term.svg b/tests/suite/cli_rustup_ui/rustup_completions_cmd_help_flag.stdout.term.svg index 4016f4f778..55a676da47 100644 --- a/tests/suite/cli_rustup_ui/rustup_completions_cmd_help_flag.stdout.term.svg +++ b/tests/suite/cli_rustup_ui/rustup_completions_cmd_help_flag.stdout.term.svg @@ -1,4 +1,4 @@ - +