summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHugo <hugo@whynothugo.nl>2023-08-31 19:08:13 +0200
committerGitHub <noreply@github.com>2023-08-31 19:08:13 +0200
commit5ca8daacd4ce936f97170f814a780b34bfaa486e (patch)
treee879d5ddea84a1080ffe1a055e9054f6d4038ecc /src
parent1884409c560a01cd1d251e8859ad78ebd932ef88 (diff)
perf: Skip unnecessary indirection in starship init zsh (#5322)
Skip unnecessary indirection in starship init zsh The installation instructions indicate that one should add this snippet to zsh's configuration: eval "$(starship init zsh)" The command `starship init zsh` prints a little shell script for zsh to execute: > starship init zsh source <(/usr/bin/starship init zsh --print-full-init)% Running `starship init zsh --print-full-init` prints yet another script that zsh executes. There is an intermediate step that seems redundant; starship prints a script for zsh to execute, and this script prints another script for zsh to execute. This commit skips the intermediate execution and prints the final script in `starship init`. This is backwards compatible and does not require any changes in the installation instructions, so it could be release without a major version bump. Note that it would still be possible to update the installation instructions to `source <(starship init zsh)`; this patch works with both `source` and `eval`. Picking the most performant one is beyond this scope of this commit. See: https://github.com/starship/starship/issues/2637
Diffstat (limited to 'src')
-rw-r--r--src/init/mod.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/init/mod.rs b/src/init/mod.rs
index f0b247c90..90399a187 100644
--- a/src/init/mod.rs
+++ b/src/init/mod.rs
@@ -153,10 +153,7 @@ pub fn init_stub(shell_name: &str) -> io::Result<()> {
"#,
starship.sprint_posix()?
),
- "zsh" => print!(
- r#"source <({} init zsh --print-full-init)"#,
- starship.sprint_posix()?
- ),
+ "zsh" => print_script(ZSH_INIT, &starship.sprint_posix()?),
"fish" => print!(
// Fish does process substitution with pipes and psub instead of bash syntax
r#"source ({} init fish --print-full-init | psub)"#,