fix(init): Change Nushell init for nu 0.60 (#3773)
This commit is contained in:
parent
1f22f76a81
commit
c9b75fe115
|
@ -41,7 +41,7 @@ assignees: ''
|
|||
- Operating system: [e.g. macOS 10.13.4, Windows 10]
|
||||
|
||||
#### Relevant Shell Configuration
|
||||
<!--
|
||||
<!--
|
||||
Based on the shell you use, please paste the appropriate configuration.
|
||||
The default location for your shell is:
|
||||
Bash: ~/.bashrc
|
||||
|
@ -49,7 +49,7 @@ assignees: ''
|
|||
Fish: ~/.config/fish/config.fish
|
||||
Xonsh: ~/.config/xonsh/rc.xsh
|
||||
Elvish: ~/.config/elvish/rc.elv
|
||||
Nushell: ~/.config/nu/config.toml
|
||||
Nushell: $nu.config-path
|
||||
Ion: ~/.config/ion/initrc
|
||||
-->
|
||||
|
||||
|
|
|
@ -437,16 +437,6 @@ dependencies = [
|
|||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "directories-next"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"dirs-sys-next",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-next"
|
||||
version = "2.0.0"
|
||||
|
@ -1564,7 +1554,7 @@ dependencies = [
|
|||
"chrono",
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"directories-next",
|
||||
"dirs-next",
|
||||
"dunce",
|
||||
"gethostname",
|
||||
"git2",
|
||||
|
|
|
@ -38,7 +38,7 @@ byte-unit = "4.0.14"
|
|||
chrono = "0.4.19"
|
||||
clap = { version = "3.1.6", features = ["derive", "cargo", "unicode"] }
|
||||
clap_complete = "3.1.1"
|
||||
directories-next = "2.0.0"
|
||||
dirs-next = "2.0.0"
|
||||
dunce = "1.0.2"
|
||||
gethostname = "0.2.3"
|
||||
git2 = { version = "0.14.2", default-features = false }
|
||||
|
|
21
README.md
21
README.md
|
@ -327,17 +327,22 @@ eval $(starship init ion)
|
|||
<details>
|
||||
<summary>Nushell</summary>
|
||||
|
||||
Add the following to the end of your Nushell configuration (find it by running `config path`):
|
||||
Run the following:
|
||||
|
||||
```toml
|
||||
startup = [
|
||||
"mkdir ~/.cache/starship",
|
||||
"starship init nu | save ~/.cache/starship/init.nu",
|
||||
"source ~/.cache/starship/init.nu",
|
||||
]
|
||||
prompt = "starship_prompt"
|
||||
```sh
|
||||
mkdir ~/.cache/starship
|
||||
starship init nu | save ~/.cache/starship/init.nu
|
||||
```
|
||||
|
||||
And add the following to the end of your Nushell configuration (find it by running `$nu.config-path`):
|
||||
|
||||
```sh
|
||||
starship init nu | save ~/.cache/starship/init.nu
|
||||
source ~/.cache/starship/init.nu
|
||||
```
|
||||
|
||||
Note: Only Nushell v0.60+ is supported
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
|
|
@ -136,20 +136,21 @@ description: Starship is the minimal, blazing fast, and extremely customizable p
|
|||
|
||||
::: warning
|
||||
This will change in the future.
|
||||
Only nu version v0.33 or higher is supported.
|
||||
Only Nushell v0.60+ is supported.
|
||||
:::
|
||||
Add the following to your nu config file. You can check the location of this
|
||||
file by running `config path` in nu.
|
||||
|
||||
```toml
|
||||
startup = [
|
||||
"mkdir ~/.cache/starship",
|
||||
"starship init nu | save ~/.cache/starship/init.nu",
|
||||
"source ~/.cache/starship/init.nu",
|
||||
]
|
||||
prompt = "starship_prompt"
|
||||
Run the following:
|
||||
```sh
|
||||
mkdir ~/.cache/starship
|
||||
starship init nu | save ~/.cache/starship/init.nu
|
||||
```
|
||||
|
||||
And add the following to the end of your Nushell configuration (find it by running `$nu.config-path`):
|
||||
|
||||
```sh
|
||||
mkdir ~/.cache/starship
|
||||
starship init nu | save ~/.cache/starship/init.nu
|
||||
source ~/.cache/starship/init.nu
|
||||
```
|
||||
#### Xonsh
|
||||
|
||||
Add the following to the end of `~/.xonshrc`:
|
||||
|
|
|
@ -512,12 +512,6 @@ look at [this example](#with-custom-error-shape).
|
|||
|
||||
::: warning
|
||||
|
||||
`error_symbol` is not supported on nu shell.
|
||||
|
||||
:::
|
||||
|
||||
::: warning
|
||||
|
||||
`vicmd_symbol` is only supported in cmd, fish and zsh.
|
||||
|
||||
:::
|
||||
|
@ -3129,10 +3123,6 @@ To enable it, set `disabled` to `false` in your configuration file.
|
|||
|
||||
:::
|
||||
|
||||
::: warning
|
||||
This module is not supported on nu shell.
|
||||
:::
|
||||
|
||||
### Options
|
||||
|
||||
| Option | Default | Description |
|
||||
|
|
|
@ -297,7 +297,7 @@ print_install() {
|
|||
# we don't want these '~' expanding
|
||||
config_file="~/.${s}rc"
|
||||
config_cmd="eval \"\$(starship init ${s})\""
|
||||
|
||||
|
||||
case ${s} in
|
||||
ion )
|
||||
# shellcheck disable=SC2088
|
||||
|
@ -336,16 +336,14 @@ print_install() {
|
|||
;;
|
||||
nushell )
|
||||
# shellcheck disable=SC2088
|
||||
config_file="your nu config file."
|
||||
config_cmd="startup = [
|
||||
\"mkdir ~/.cache/starship\",
|
||||
\"starship init nu | save ~/.cache/starship/init.nu\",
|
||||
\"source ~/.cache/starship/init.nu\"
|
||||
]
|
||||
prompt = \"starship_prompt\""
|
||||
config_file="your nu config file"
|
||||
config_cmd="mkdir ~/.cache/starship
|
||||
starship init nu | save ~/.cache/starship/init.nu
|
||||
source ~/.cache/starship/init.nu"
|
||||
warning="${warning} This will change in the future.
|
||||
Only nu version v0.33 or higher is supported.
|
||||
You can check the location of this your config file by running config path in nu"
|
||||
Only Nushell v0.60 or higher is supported.
|
||||
You can check the location of this your config file by running \$nu.config-path in nu.
|
||||
${BOLD}First run${NO_COLOR} \"mkdir ~/.cache/starship; starship init nu | save ~/.cache/starship/init.nu\""
|
||||
;;
|
||||
esac
|
||||
printf " %s\n %s\n Add the following to the end of %s:\n\n\t%s\n\n" \
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::shadow;
|
||||
use crate::utils::{self, exec_cmd};
|
||||
|
||||
use directories_next::ProjectDirs;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
|
@ -181,8 +180,8 @@ fn get_terminal_info() -> TerminalInfo {
|
|||
|
||||
fn get_config_path(shell: &str) -> Option<PathBuf> {
|
||||
if shell == "nu" {
|
||||
return ProjectDirs::from("org", "nushell", "nu")
|
||||
.map(|project_dirs| project_dirs.config_dir().join("config.toml"));
|
||||
return dirs_next::config_dir()
|
||||
.map(|config_dir| config_dir.join("nushell").join("config.nu"));
|
||||
}
|
||||
|
||||
utils::home_dir().and_then(|home_dir| {
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
let-env STARSHIP_SHELL = "nu"
|
||||
let-env STARSHIP_SESSION_KEY = (random chars -l 16)
|
||||
let-env PROMPT_MULTILINE_INDICATOR = (^::STARSHIP:: prompt --continuation)
|
||||
|
||||
def starship_prompt [] {
|
||||
# Does not play well with default character module.
|
||||
# TODO: Also Use starship vi mode indicators?
|
||||
let-env PROMPT_INDICATOR = ""
|
||||
|
||||
let-env PROMPT_COMMAND = {
|
||||
# jobs are not supported
|
||||
# status is not supported
|
||||
^::STARSHIP:: prompt --cmd-duration $nu.env.CMD_DURATION_MS
|
||||
^::STARSHIP:: prompt --cmd-duration $env.CMD_DURATION_MS --status $env.LAST_EXIT_CODE
|
||||
}
|
||||
|
||||
# Not well-suited for `starship prompt --right`.
|
||||
# Built-in right prompt is equivalent to $fill$right_format in the first prompt line.
|
||||
# Thus does not play well with default `add_newline = True`.
|
||||
let-env PROMPT_COMMAND_RIGHT = {''}
|
||||
|
|
|
@ -516,7 +516,7 @@ fn render_time_component((component, suffix): (&u128, &&str)) -> String {
|
|||
}
|
||||
|
||||
pub fn home_dir() -> Option<PathBuf> {
|
||||
directories_next::BaseDirs::new().map(|base_dirs| base_dirs.home_dir().to_owned())
|
||||
dirs_next::home_dir()
|
||||
}
|
||||
|
||||
const HEXTABLE: &[char] = &[
|
||||
|
|
Loading…
Reference in New Issue