Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/user-guide/src/installation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,5 @@ For `zsh`, you must then add the following line in your `~/.zshrc` before
```zsh
fpath+=~/.zfunc
```

In Xonsh you can reuse Fish completion by installing [xontrib-fish-completer](https://github.com/xonsh/xontrib-fish-completer).
4 changes: 4 additions & 0 deletions src/cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
"#
};
}
Expand Down
1 change: 1 addition & 0 deletions src/cli/self_update/env.xsh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$PATH.append(_cargo_bin) if (_cargo_bin := '{cargo_bin}') not in $PATH else None
57 changes: 57 additions & 0 deletions src/cli/self_update/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fn enumerate_shells() -> Vec<Shell> {
Box::new(Nu),
Box::new(Tcsh),
Box::new(Pwsh),
Box::new(Xonsh),
]
}

Expand Down Expand Up @@ -445,6 +446,62 @@ 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<PathBuf> {
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<PathBuf> {
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<String> {
Ok(format!(
r#"source "{}/env.xsh""#,
self.cargo_home_str(process)?
))
}
}

pub(crate) fn legacy_paths(process: &Process) -> impl Iterator<Item = PathBuf> + '_ {
let zprofiles = Zsh::zdotdir(process)
.into_iter()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.