Skip to content

Commit

Permalink
add trim_prompt option
Browse files Browse the repository at this point in the history
  • Loading branch information
kkpattern committed Apr 8, 2024
1 parent f2057f9 commit 5800c6b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,10 @@
"default": true,
"type": "boolean"
},
"trim_prompt": {
"default": false,
"type": "boolean"
},
"follow_symlinks": {
"default": true,
"type": "boolean"
Expand Down
2 changes: 2 additions & 0 deletions src/configs/starship_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct StarshipRootConfig {
pub scan_timeout: u64,
pub command_timeout: u64,
pub add_newline: bool,
pub trim_prompt: bool,
pub follow_symlinks: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub palette: Option<String>,
Expand Down Expand Up @@ -140,6 +141,7 @@ impl Default for StarshipRootConfig {
scan_timeout: 30,
command_timeout: 500,
add_newline: true,
trim_prompt: false,
follow_symlinks: true,
palette: None,
palettes: HashMap::default(),
Expand Down
7 changes: 6 additions & 1 deletion src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ pub fn get_prompt(context: Context) -> String {
// color sequences for this specific shell
let shell_wrapped_output =
wrap_colorseq_for_shell(AnsiStrings(&module_strings).to_string(), context.shell);
write!(buf, "{}", shell_wrapped_output).unwrap();

if config.trim_prompt {
write!(buf, "{}", shell_wrapped_output.trim()).unwrap();
} else {
write!(buf, "{}", shell_wrapped_output).unwrap();
}

if context.target == Target::Right {
// right prompts generally do not allow newlines
Expand Down

0 comments on commit 5800c6b

Please sign in to comment.