From d7e95cdb42bcd761fc537cfaf1c8e99beaca312b Mon Sep 17 00:00:00 2001 From: Texas Toland Date: Sat, 16 Mar 2024 15:08:39 -0500 Subject: [PATCH 1/3] Simplify Nushell integration Motivated by jdx/mise-docs#46 for consistency between tools. --- docs/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/README.md b/docs/README.md index 2cf7a0c2739b..fac17c5e2009 100644 --- a/docs/README.md +++ b/docs/README.md @@ -137,24 +137,24 @@ description: Starship is the minimal, blazing fast, and extremely customizable p #### Nushell - ::: warning - - This will change in the future. - Only Nushell v0.78+ is supported. + Since Nu does [not support `eval`](https://www.nushell.sh/book/how_nushell_code_gets_run.html#eval-function) you must save the initialization script: - ::: + ```nushell + let starship_path = $nu.default-config-dir | path join scripts starship.nu + starship init nu | save $starship_path --force + "\nuse starship.nu" | save $nu.config-path --append + ``` - Add the following to the end of your Nushell env file (find it by running `$nu.env-path` in Nushell): + If you prefer to keep your dotfiles clean you can save it to another directory then update `$env.NU_LIB_DIRS`: - ```sh - mkdir ~/.cache/starship - starship init nu | save -f ~/.cache/starship/init.nu + ```nushell + "\n$env.NU_LIB_DIRS ++= ($starship_path | path dirname | to nuon)" | save $nu.env-path --append ``` - And add the following to the end of your Nushell configuration (find it by running `$nu.config-path`): + You can update the generated script at any time by re-running: - ```sh - use ~/.cache/starship/init.nu + ```nushell + starship init nu | save $starship_path --force ``` #### Xonsh From d7826592eb4af8af9c2a355d226945b3bd69aab9 Mon Sep 17 00:00:00 2001 From: Texas Toland Date: Sun, 17 Mar 2024 12:37:45 -0500 Subject: [PATCH 2/3] Implement maintainer feedback Reinitializes the script at most once every day. This is necessary because doing so every time could lead to thousands of concurrent writes calling `| par-each { nu -c }`. --- README.md | 27 +++++++++++++++++---------- docs/README.md | 24 +++++++++++++----------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 2c87fd812255..87ee8a7c1994 100644 --- a/README.md +++ b/README.md @@ -339,21 +339,28 @@ eval $(starship init ion)
Nushell -Add the following to the end of your Nushell env file (find it by running `$nu.env-path` in Nushell): - -```sh -mkdir ~/.cache/starship -starship init nu | save -f ~/.cache/starship/init.nu +Since Nu does [not support `eval`](https://www.nushell.sh/book/how_nushell_code_gets_run.html#eval-function) the initialization script is saved in `env.nu`: + +```nushell +' +let starship_path = $nu.default-config-dir | path join scripts starship.nu +if $nu.is-interactive { + starship init nu | save $starship_path --force +}' | save $nu.env-path --append +' +if $nu.is-interactive { + use starship.nu +}' | save $nu.config-path --append ``` -And add the following to the end of your Nushell configuration (find it by running `$nu.config-path`): +If you prefer to keep your dotfiles clean you can save it to a different directory then update `$env.NU_LIB_DIRS`: -```sh -use ~/.cache/starship/init.nu +```nushell +' +$env.NU_LIB_DIRS ++= ($starship_path | path dirname | to nuon) +' | save $nu.env-path --append ``` -Note: Only Nushell v0.78+ is supported -
diff --git a/docs/README.md b/docs/README.md index fac17c5e2009..8d0079090e5a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -137,24 +137,26 @@ description: Starship is the minimal, blazing fast, and extremely customizable p #### Nushell - Since Nu does [not support `eval`](https://www.nushell.sh/book/how_nushell_code_gets_run.html#eval-function) you must save the initialization script: + Since Nu does [not support `eval`](https://www.nushell.sh/book/how_nushell_code_gets_run.html#eval-function) the initialization script is saved in `env.nu`: ```nushell + ' let starship_path = $nu.default-config-dir | path join scripts starship.nu - starship init nu | save $starship_path --force - "\nuse starship.nu" | save $nu.config-path --append + if $nu.is-interactive { + starship init nu | save $starship_path --force + }' | save $nu.env-path --append + ' + if $nu.is-interactive { + use starship.nu + }' | save $nu.config-path --append ``` - If you prefer to keep your dotfiles clean you can save it to another directory then update `$env.NU_LIB_DIRS`: + If you prefer to keep your dotfiles clean you can save it to a different directory then update `$env.NU_LIB_DIRS`: ```nushell - "\n$env.NU_LIB_DIRS ++= ($starship_path | path dirname | to nuon)" | save $nu.env-path --append - ``` - - You can update the generated script at any time by re-running: - - ```nushell - starship init nu | save $starship_path --force + ' + $env.NU_LIB_DIRS ++= ($starship_path | path dirname | to nuon) + ' | save $nu.env-path --append ``` #### Xonsh From 1d2f4d8c02209bf2dae609554a4543df3422aab4 Mon Sep 17 00:00:00 2001 From: Texas Toland Date: Sat, 23 Mar 2024 09:30:41 -0500 Subject: [PATCH 3/3] Implement Nu contributor feedback --- README.md | 14 ++++---------- docs/README.md | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 87ee8a7c1994..e9f19fcddf7c 100644 --- a/README.md +++ b/README.md @@ -344,21 +344,15 @@ Since Nu does [not support `eval`](https://www.nushell.sh/book/how_nushell_code_ ```nushell ' let starship_path = $nu.default-config-dir | path join scripts starship.nu -if $nu.is-interactive { - starship init nu | save $starship_path --force -}' | save $nu.env-path --append -' -if $nu.is-interactive { - use starship.nu -}' | save $nu.config-path --append +starship init nu | save $starship_path --force +' | save $nu.env-path --append +"\nuse starship.nu" | save $nu.config-path --append ``` If you prefer to keep your dotfiles clean you can save it to a different directory then update `$env.NU_LIB_DIRS`: ```nushell -' -$env.NU_LIB_DIRS ++= ($starship_path | path dirname | to nuon) -' | save $nu.env-path --append +"\n$env.NU_LIB_DIRS ++= ($starship_path | path dirname | to nuon)" | save $nu.env-path --append ```
diff --git a/docs/README.md b/docs/README.md index 8d0079090e5a..3f7241534562 100644 --- a/docs/README.md +++ b/docs/README.md @@ -142,21 +142,15 @@ description: Starship is the minimal, blazing fast, and extremely customizable p ```nushell ' let starship_path = $nu.default-config-dir | path join scripts starship.nu - if $nu.is-interactive { - starship init nu | save $starship_path --force - }' | save $nu.env-path --append - ' - if $nu.is-interactive { - use starship.nu - }' | save $nu.config-path --append + starship init nu | save $starship_path --force + ' | save $nu.env-path --append + "\nuse starship.nu" | save $nu.config-path --append ``` If you prefer to keep your dotfiles clean you can save it to a different directory then update `$env.NU_LIB_DIRS`: ```nushell - ' - $env.NU_LIB_DIRS ++= ($starship_path | path dirname | to nuon) - ' | save $nu.env-path --append + "\n$env.NU_LIB_DIRS ++= ($starship_path | path dirname | to nuon)" | save $nu.env-path --append ``` #### Xonsh