diff options
author | David Knaack <davidkna@users.noreply.github.com> | 2022-03-24 20:06:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 15:06:24 -0400 |
commit | c9b75fe115075c23eb456df5b1af8f4491834aaf (patch) | |
tree | d921255a1a0e06900da545802cf2f46e60528552 /src | |
parent | 1f22f76a81df3a0f5065c47c6b3d21db6440f322 (diff) |
fix(init): Change Nushell init for nu 0.60 (#3773)
Diffstat (limited to 'src')
-rw-r--r-- | src/bug_report.rs | 5 | ||||
-rw-r--r-- | src/init/starship.nu | 15 | ||||
-rw-r--r-- | src/utils.rs | 2 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/bug_report.rs b/src/bug_report.rs index c2ed9a127..9a89eb6ec 100644 --- a/src/bug_report.rs +++ b/src/bug_report.rs @@ -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| { diff --git a/src/init/starship.nu b/src/init/starship.nu index b7fb93a36..f31729142 100644 --- a/src/init/starship.nu +++ b/src/init/starship.nu @@ -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 = {''} diff --git a/src/utils.rs b/src/utils.rs index db78172ce..b6820124d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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] = &[ |