fix: use suffixes for modules before directory (#1645)
Previously, all modules would have prefixes, which lead to the first module having a dangling prefix. This change ensures that the first few modules would instead have suffixes so that we don't start or end with a prefix or suffix.
This commit is contained in:
parent
17e8115f16
commit
d3100c5c82
|
@ -7,6 +7,7 @@ mkdir -p ~/.config && touch ~/.config/starship.toml
|
|||
```
|
||||
|
||||
All configuration for starship is done in this [TOML](https://github.com/toml-lang/toml) file:
|
||||
|
||||
```toml
|
||||
# Don't print a new line at the start of the prompt
|
||||
add_newline = false
|
||||
|
@ -101,7 +102,7 @@ For example:
|
|||
The following symbols have special usage in a format string.
|
||||
If you want to print the following symbols, you have to escape them with a backslash (`\`).
|
||||
|
||||
- $
|
||||
- \$
|
||||
- \\
|
||||
- [
|
||||
- ]
|
||||
|
@ -874,7 +875,7 @@ The module will be shown only if any of the following conditions are met:
|
|||
|
||||
| Variable | Example | Description |
|
||||
| --------- | ------------------------------------------- | ------------------------------------------ |
|
||||
| env_value | `Windows NT` (if *variable* would be `$OS`) | The environment value of option `variable` |
|
||||
| env_value | `Windows NT` (if _variable_ would be `$OS`) | The environment value of option `variable` |
|
||||
| symbol | | Mirrors the value of option `symbol` |
|
||||
| style\* | `black bold dimmed` | Mirrors the value of option `style` |
|
||||
|
||||
|
@ -902,7 +903,7 @@ The module will be shown if any of the following conditions are met:
|
|||
|
||||
| Option | Default | Description |
|
||||
| ---------- | ---------------------------------- | -------------------------------------------------------- |
|
||||
| `symbol` | `"🖧 "` | The symbol used before displaying the version of erlang. |
|
||||
| `symbol` | `"🖧 "` | The symbol used before displaying the version of erlang. |
|
||||
| `style` | `"bold red"` | The style for the module. |
|
||||
| `format` | `"via [$symbol$version]($style) "` | The format for the module. |
|
||||
| `disabled` | `false` | Disables the `erlang` module. |
|
||||
|
@ -933,13 +934,13 @@ This is based on the `~/.config/gcloud/active_config` file and the `~/.config/gc
|
|||
|
||||
### Options
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ----------------- | ------------------------------------------------- | --------------------------------------------------------------------------- |
|
||||
| `format` | `"on [$symbol$account(\\($region\\))]($style) "` | The format for the module. |
|
||||
| `symbol` | `"☁️ "` | The symbol used before displaying the current GCP profile. |
|
||||
| `region_aliases` | | Table of region aliases to display in addition to the GCP name. |
|
||||
| `style` | `"bold blue"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `gcloud` module. |
|
||||
| Variable | Default | Description |
|
||||
| ---------------- | ------------------------------------------------ | --------------------------------------------------------------- |
|
||||
| `format` | `"on [$symbol$account(\\($region\\))]($style) "` | The format for the module. |
|
||||
| `symbol` | `"☁️ "` | The symbol used before displaying the current GCP profile. |
|
||||
| `region_aliases` | | Table of region aliases to display in addition to the GCP name. |
|
||||
| `style` | `"bold blue"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `gcloud` module. |
|
||||
|
||||
### Variables
|
||||
|
||||
|
@ -995,7 +996,7 @@ The `git_branch` module shows the active branch of the repo in your current dire
|
|||
|
||||
| Option | Default | Description |
|
||||
| ------------------- | -------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| `format` | `"on [$symbol$branch]($style) "` | The format for the module. Use `"$branch"` to refer to the current branch name. |
|
||||
| `format` | `"on [$symbol$branch]($style) "` | The format for the module. Use `"$branch"` to refer to the current branch name. |
|
||||
| `symbol` | `" "` | A format string representing the symbol of git branch. |
|
||||
| `style` | `"bold purple"` | The style for the module. |
|
||||
| `truncation_length` | `2^63 - 1` | Truncates a git branch to X graphemes. |
|
||||
|
@ -1131,12 +1132,12 @@ The following variables can be used in `format`:
|
|||
| `all_status` | Shortcut for`$conflicted$stashed$deleted$renamed$modified$staged$untracked` |
|
||||
| `ahead_behind` | Displays `diverged` `ahead` or `behind` format string based on the current status of the repo |
|
||||
| `conflicted` | Displays `conflicted` when this branch has merge conflicts. |
|
||||
| `untracked` | Displays `untracked` when there are untracked files in the working directory. |
|
||||
| `stashed` | Displays `stashed` when a stash exists for the local repository. |
|
||||
| `modified` | Displays `modified` when there are file modifications in the working directory. |
|
||||
| `staged` | Displays `staged` when a new file has been added to the staging area. |
|
||||
| `renamed` | Displays `renamed` when a renamed file has been added to the staging area. |
|
||||
| `deleted` | Displays `deleted` when a file's deletion has been added to the staging area. |
|
||||
| `untracked` | Displays `untracked` when there are untracked files in the working directory. |
|
||||
| `stashed` | Displays `stashed` when a stash exists for the local repository. |
|
||||
| `modified` | Displays `modified` when there are file modifications in the working directory. |
|
||||
| `staged` | Displays `staged` when a new file has been added to the staging area. |
|
||||
| `renamed` | Displays `renamed` when a renamed file has been added to the staging area. |
|
||||
| `deleted` | Displays `deleted` when a file's deletion has been added to the staging area. |
|
||||
| style\* | Mirrors the value of option `style` |
|
||||
|
||||
\*: This variable can only be used as a part of a style string
|
||||
|
@ -1224,20 +1225,20 @@ The module will be shown if any of the following conditions are met:
|
|||
|
||||
### Options
|
||||
|
||||
| Option | Default | Description |
|
||||
| ---------- | ---------------------------------- | ---------------------------------------------- |
|
||||
| `format` | `"via [$symbol$version]($style) "` | The format for the module. |
|
||||
| `symbol` | `"⎈ "` | A format string representing the symbol of Helm. |
|
||||
| `style` | `"bold white"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `helm` module. |
|
||||
| Option | Default | Description |
|
||||
| ---------- | ---------------------------------- | ------------------------------------------------ |
|
||||
| `format` | `"via [$symbol$version]($style) "` | The format for the module. |
|
||||
| `symbol` | `"⎈ "` | A format string representing the symbol of Helm. |
|
||||
| `style` | `"bold white"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `helm` module. |
|
||||
|
||||
### Variables
|
||||
|
||||
| Variable | Example | Description |
|
||||
| -------- | --------- | ------------------------------------ |
|
||||
| version | `v3.1.1` | The version of `helm` |
|
||||
| symbol | | Mirrors the value of option `symbol` |
|
||||
| style\* | | Mirrors the value of option `style` |
|
||||
| Variable | Example | Description |
|
||||
| -------- | -------- | ------------------------------------ |
|
||||
| version | `v3.1.1` | The version of `helm` |
|
||||
| symbol | | Mirrors the value of option `symbol` |
|
||||
| style\* | | Mirrors the value of option `style` |
|
||||
|
||||
\*: This variable can only be used as a part of a style string
|
||||
|
||||
|
@ -1260,7 +1261,7 @@ The `hostname` module shows the system hostname.
|
|||
| ---------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `ssh_only` | `true` | Only show hostname when connected to an SSH session. |
|
||||
| `trim_at` | `"."` | String that the hostname is cut off at, after the first match. `"."` will stop after the first dot. `""` will disable any truncation |
|
||||
| `format` | `"on [$hostname]($style) "` | The format for the module. |
|
||||
| `format` | `"[$hostname]($style) in "` | The format for the module. |
|
||||
| `style` | `"bold dimmed green"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `hostname` module. |
|
||||
|
||||
|
@ -1413,8 +1414,8 @@ To enable it, set `disabled` to `false` in your configuration file.
|
|||
|
||||
| Option | Default | Description |
|
||||
| ----------------------- | ---------------------------------------------------- | --------------------------------------------------------------------- |
|
||||
| `symbol` | `"☸ "` | A format string representing the symbol displayed before the Cluster. |
|
||||
| `format` | `"on [$symbol$context( \\($namespace\\))]($style) "` | The format for the module. |
|
||||
| `symbol` | `"☸ "` | A format string representing the symbol displayed before the Cluster. |
|
||||
| `format` | `"[$symbol$context( \\($namespace\\))]($style) in "` | The format for the module. |
|
||||
| `style` | `"cyan bold"` | The style for the module. |
|
||||
| `namespace_spaceholder` | `none` | The value to display if no namespace was found. |
|
||||
| `context_aliases` | | Table of context aliases to display. |
|
||||
|
@ -1487,14 +1488,14 @@ To enable it, set `disabled` to `false` in your configuration file.
|
|||
|
||||
### Variables
|
||||
|
||||
| Variable | Example | Description |
|
||||
| ----------- | ------------- | ------------------------------------------------------------------ |
|
||||
| ram | `31GiB/65GiB` | The usage/total RAM of the current system memory. |
|
||||
| ram_pct | `48%` | The percentage of the current system memory. |
|
||||
| swap\** | `1GiB/4GiB` | The swap memory size of the current system swap memory file. |
|
||||
| swap_pct\** | `77%` | The swap memory percentage of the current system swap memory file. |
|
||||
| symbol | `🐏` | Mirrors the value of option `symbol` |
|
||||
| style\* | | Mirrors the value of option `style` |
|
||||
| Variable | Example | Description |
|
||||
| ------------ | ------------- | ------------------------------------------------------------------ |
|
||||
| ram | `31GiB/65GiB` | The usage/total RAM of the current system memory. |
|
||||
| ram_pct | `48%` | The percentage of the current system memory. |
|
||||
| swap\*\* | `1GiB/4GiB` | The swap memory size of the current system swap memory file. |
|
||||
| swap_pct\*\* | `77%` | The swap memory percentage of the current system swap memory file. |
|
||||
| symbol | `🐏` | Mirrors the value of option `symbol` |
|
||||
| style\* | | Mirrors the value of option `style` |
|
||||
|
||||
\*: This variable can only be used as a part of a style string
|
||||
\*\*: The SWAP file information is only displayed if detected on the current system
|
||||
|
@ -1599,7 +1600,7 @@ The module will be shown when inside a nix-shell environment.
|
|||
| Option | Default | Description |
|
||||
| ------------ | ---------------------------------------------- | ----------------------------------------------------- |
|
||||
| `format` | `"via [$symbol$state( \\($name\\))]($style) "` | The format for the module. |
|
||||
| `symbol` | `"❄️ "` | A format string representing the symbol of nix-shell. |
|
||||
| `symbol` | `"❄️ "` | A format string representing the symbol of nix-shell. |
|
||||
| `style` | `"bold blue"` | The style for the module. |
|
||||
| `impure_msg` | `"impure"` | A format string shown when the shell is impure. |
|
||||
| `pure_msg` | `"pure"` | A format string shown when the shell is pure. |
|
||||
|
@ -1759,7 +1760,6 @@ The module will be shown if any of the following conditions are met:
|
|||
format = "via [🐪 $version]($style) "
|
||||
```
|
||||
|
||||
|
||||
## Perl
|
||||
|
||||
The `perl` module shows the currently installed version of Perl.
|
||||
|
@ -1774,8 +1774,8 @@ The module will be shown if any of the following conditions are met:
|
|||
### Options
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ---------- |----------------------------------- | ----------------------------------------------------- |
|
||||
| `format` | `"via [$symbol$version]($style) "` | The format string for the module.|
|
||||
| ---------- | ---------------------------------- | ----------------------------------------------------- |
|
||||
| `format` | `"via [$symbol$version]($style) "` | The format string for the module. |
|
||||
| `symbol` | `"🐪 "` | The symbol used before displaying the version of Perl |
|
||||
| `style` | `"bold 149"` | The style for the module. |
|
||||
| `disabled` | `false` | Disables the `perl` module. |
|
||||
|
@ -1797,7 +1797,6 @@ The module will be shown if any of the following conditions are met:
|
|||
format = "via [🦪 $version]($style) "
|
||||
```
|
||||
|
||||
|
||||
## PHP
|
||||
|
||||
The `php` module shows the currently installed version of PHP.
|
||||
|
@ -1985,21 +1984,21 @@ set to a number and meets or exceeds the specified threshold.
|
|||
|
||||
### Options
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ----------- | ---------------------------- | ------------------------------------------------ |
|
||||
| `threshold` | `2` | Display threshold. |
|
||||
| `format` | `"[$symbol$shlvl]($style) "` | The format for the module. |
|
||||
| `symbol` | `"↕️ "` | The symbol used to represent the SHLVL. |
|
||||
| `style` | `"bold yellow"` | The style for the module. |
|
||||
| `disabled` | `true` | Disables the `shlvl` module. |
|
||||
| Variable | Default | Description |
|
||||
| ----------- | ---------------------------- | --------------------------------------- |
|
||||
| `threshold` | `2` | Display threshold. |
|
||||
| `format` | `"[$symbol$shlvl]($style) "` | The format for the module. |
|
||||
| `symbol` | `"↕️ "` | The symbol used to represent the SHLVL. |
|
||||
| `style` | `"bold yellow"` | The style for the module. |
|
||||
| `disabled` | `true` | Disables the `shlvl` module. |
|
||||
|
||||
### Variables
|
||||
|
||||
| Variable | Example | Description |
|
||||
| -------- | --------- | ------------------------------------ |
|
||||
| shlvl | `3` | The current value of SHLVL |
|
||||
| symbol | | Mirrors the value of option `symbol` |
|
||||
| style\* | | Mirrors the value of option `style` |
|
||||
| Variable | Example | Description |
|
||||
| -------- | ------- | ------------------------------------ |
|
||||
| shlvl | `3` | The current value of SHLVL |
|
||||
| symbol | | Mirrors the value of option `symbol` |
|
||||
| style\* | | Mirrors the value of option `style` |
|
||||
|
||||
\*: This variable can only be used as a part of a style string
|
||||
|
||||
|
@ -2194,13 +2193,13 @@ The module will be shown if any of the following conditions are met:
|
|||
|
||||
### Options
|
||||
|
||||
| Option | Default | Description |
|
||||
| ------------- | ------------------------ | ------------------------------------- |
|
||||
| `style_root` | `"bold red"` | The style used when the user is root. |
|
||||
| `style_user` | `"bold yellow"` | The style used for non-root users. |
|
||||
| `format` | `"via [$user]($style) "` | The format for the module. |
|
||||
| `show_always` | `false` | Always shows the `username` module. |
|
||||
| `disabled` | `false` | Disables the `username` module. |
|
||||
| Option | Default | Description |
|
||||
| ------------- | ----------------------- | ------------------------------------- |
|
||||
| `style_root` | `"bold red"` | The style used when the user is root. |
|
||||
| `style_user` | `"bold yellow"` | The style used for non-root users. |
|
||||
| `format` | `"[$user]($style) in "` | The format for the module. |
|
||||
| `show_always` | `false` | Always shows the `username` module. |
|
||||
| `disabled` | `false` | Disables the `username` module. |
|
||||
|
||||
### Variables
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ impl<'a> RootModuleConfig<'a> for HostnameConfig<'a> {
|
|||
HostnameConfig {
|
||||
ssh_only: true,
|
||||
trim_at: ".",
|
||||
format: "on [$hostname]($style) ",
|
||||
format: "[$hostname]($style) in ",
|
||||
style: "green dimmed bold",
|
||||
disabled: false,
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ impl<'a> RootModuleConfig<'a> for KubernetesConfig<'a> {
|
|||
fn new() -> Self {
|
||||
KubernetesConfig {
|
||||
symbol: "☸ ",
|
||||
format: "on [$symbol$context( \\($namespace\\))]($style) ",
|
||||
format: "[$symbol$context( \\($namespace\\))]($style) in ",
|
||||
style: "cyan bold",
|
||||
disabled: true,
|
||||
context_aliases: HashMap::new(),
|
||||
|
|
|
@ -14,7 +14,7 @@ pub struct UsernameConfig<'a> {
|
|||
impl<'a> RootModuleConfig<'a> for UsernameConfig<'a> {
|
||||
fn new() -> Self {
|
||||
UsernameConfig {
|
||||
format: "via [$user]($style) ",
|
||||
format: "[$user]($style) in ",
|
||||
style_root: "red bold",
|
||||
style_user: "yellow bold",
|
||||
show_always: false,
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::fmt;
|
|||
|
||||
// List of all modules
|
||||
// Keep these ordered alphabetically.
|
||||
// Default ordering is handled in configs/mod.rs
|
||||
// Default ordering is handled in configs/starship_root.rs
|
||||
pub const ALL_MODULES: &[&str] = &[
|
||||
"aws",
|
||||
#[cfg(feature = "battery")]
|
||||
|
|
|
@ -95,7 +95,7 @@ mod tests {
|
|||
trim_at = ""
|
||||
})
|
||||
.collect();
|
||||
let expected = Some(format!("on {} ", style().paint(hostname)));
|
||||
let expected = Some(format!("{} in ", style().paint(hostname)));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
|
@ -126,7 +126,7 @@ mod tests {
|
|||
})
|
||||
.env("SSH_CONNECTION", "something")
|
||||
.collect();
|
||||
let expected = Some(format!("on {} ", style().paint(hostname)));
|
||||
let expected = Some(format!("{} in ", style().paint(hostname)));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
|
@ -142,7 +142,7 @@ mod tests {
|
|||
trim_at = ""
|
||||
})
|
||||
.collect();
|
||||
let expected = Some(format!("on {} ", style().paint(hostname)));
|
||||
let expected = Some(format!("{} in ", style().paint(hostname)));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
|
@ -159,7 +159,7 @@ mod tests {
|
|||
trim_at = trim_at
|
||||
})
|
||||
.collect();
|
||||
let expected = Some(format!("on {} ", style().paint(remainder)));
|
||||
let expected = Some(format!("{} in ", style().paint(remainder)));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
|
|
|
@ -59,7 +59,7 @@ use crate::module::Module;
|
|||
pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
|
||||
match module {
|
||||
// Keep these ordered alphabetically.
|
||||
// Default ordering is handled in configs/mod.rs
|
||||
// Default ordering is handled in configs/starship_root.rs
|
||||
"aws" => aws::module(context),
|
||||
#[cfg(feature = "battery")]
|
||||
"battery" => battery::module(context),
|
||||
|
|
|
@ -111,7 +111,7 @@ mod tests {
|
|||
.env("LOGNAME", "astronaut")
|
||||
.env("USER", "cosmonaut")
|
||||
.collect();
|
||||
let expected = Some(format!("via {} ", Color::Yellow.bold().paint("cosmonaut")));
|
||||
let expected = Some(format!("{} in ", Color::Yellow.bold().paint("cosmonaut")));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
|
@ -123,7 +123,7 @@ mod tests {
|
|||
.env("USER", "astronaut")
|
||||
.env("SSH_CONNECTION", "192.168.223.17 36673 192.168.223.229 22")
|
||||
.collect();
|
||||
let expected = Some(format!("via {} ", Color::Yellow.bold().paint("astronaut")));
|
||||
let expected = Some(format!("{} in ", Color::Yellow.bold().paint("astronaut")));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
|
@ -138,7 +138,7 @@ mod tests {
|
|||
show_always = true
|
||||
})
|
||||
.collect();
|
||||
let expected = Some(format!("via {} ", Color::Yellow.bold().paint("astronaut")));
|
||||
let expected = Some(format!("{} in ", Color::Yellow.bold().paint("astronaut")));
|
||||
|
||||
assert_eq!(expected, actual);
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue