mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-28 07:46:28 +00:00
feat(directory): add before_repo_root_style (#4595)
This commit is contained in:
parent
ddd54e9b20
commit
ea6249b524
12
.github/config-schema.json
vendored
12
.github/config-schema.json
vendored
@ -330,13 +330,14 @@
|
|||||||
},
|
},
|
||||||
"directory": {
|
"directory": {
|
||||||
"default": {
|
"default": {
|
||||||
|
"before_repo_root_style": null,
|
||||||
"disabled": false,
|
"disabled": false,
|
||||||
"fish_style_pwd_dir_length": 0,
|
"fish_style_pwd_dir_length": 0,
|
||||||
"format": "[$path]($style)[$read_only]($read_only_style) ",
|
"format": "[$path]($style)[$read_only]($read_only_style) ",
|
||||||
"home_symbol": "~",
|
"home_symbol": "~",
|
||||||
"read_only": "🔒",
|
"read_only": "🔒",
|
||||||
"read_only_style": "red",
|
"read_only_style": "red",
|
||||||
"repo_root_format": "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ",
|
"repo_root_format": "[$before_root_path]($before_repo_root_style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ",
|
||||||
"repo_root_style": null,
|
"repo_root_style": null,
|
||||||
"style": "cyan bold",
|
"style": "cyan bold",
|
||||||
"substitutions": {},
|
"substitutions": {},
|
||||||
@ -2468,7 +2469,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"repo_root_format": {
|
"repo_root_format": {
|
||||||
"default": "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ",
|
"default": "[$before_root_path]($before_repo_root_style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"style": {
|
"style": {
|
||||||
@ -2482,6 +2483,13 @@
|
|||||||
"null"
|
"null"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"before_repo_root_style": {
|
||||||
|
"default": null,
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
"disabled": {
|
"disabled": {
|
||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
@ -1104,7 +1104,7 @@ it would have been `nixpkgs/pkgs`.
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
| ------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||||
| `truncation_length` | `3` | The number of parent folders that the current directory should be truncated to. |
|
| `truncation_length` | `3` | The number of parent folders that the current directory should be truncated to. |
|
||||||
| `truncate_to_repo` | `true` | Whether or not to truncate to the root of the git repo that you're currently in. |
|
| `truncate_to_repo` | `true` | Whether or not to truncate to the root of the git repo that you're currently in. |
|
||||||
| `format` | `'[$path]($style)[$read_only]($read_only_style) '` | The format for the module. |
|
| `format` | `'[$path]($style)[$read_only]($read_only_style) '` | The format for the module. |
|
||||||
@ -1113,8 +1113,9 @@ it would have been `nixpkgs/pkgs`.
|
|||||||
| `read_only` | `'🔒'` | The symbol indicating current directory is read only. |
|
| `read_only` | `'🔒'` | The symbol indicating current directory is read only. |
|
||||||
| `read_only_style` | `'red'` | The style for the read only symbol. |
|
| `read_only_style` | `'red'` | The style for the read only symbol. |
|
||||||
| `truncation_symbol` | `''` | The symbol to prefix to truncated paths. eg: '…/' |
|
| `truncation_symbol` | `''` | The symbol to prefix to truncated paths. eg: '…/' |
|
||||||
|
| `before_repo_root_style` | | The style for the path segment above the root of the git repo. The default value is equivalent to `style`. |
|
||||||
| `repo_root_style` | | The style for the root of the git repo. The default value is equivalent to `style`. |
|
| `repo_root_style` | | The style for the root of the git repo. The default value is equivalent to `style`. |
|
||||||
| `repo_root_format` | `'[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) '` | The format of a git repo when `repo_root_style` is defined. |
|
| `repo_root_format` | `'[$before_root_path]($before_repo_root_style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) '` | The format of a git repo when `before_repo_root_style` and `repo_root_style` is defined. |
|
||||||
| `home_symbol` | `'~'` | The symbol indicating home directory. |
|
| `home_symbol` | `'~'` | The symbol indicating home directory. |
|
||||||
| `use_os_path_sep` | `true` | Use the OS specific path separator instead of always using `/` (e.g. `\` on Windows) |
|
| `use_os_path_sep` | `true` | Use the OS specific path separator instead of always using `/` (e.g. `\` on Windows) |
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ pub struct DirectoryConfig<'a> {
|
|||||||
pub repo_root_format: &'a str,
|
pub repo_root_format: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
pub repo_root_style: Option<&'a str>,
|
pub repo_root_style: Option<&'a str>,
|
||||||
|
pub before_repo_root_style: Option<&'a str>,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
pub read_only: &'a str,
|
pub read_only: &'a str,
|
||||||
pub read_only_style: &'a str,
|
pub read_only_style: &'a str,
|
||||||
@ -36,9 +37,10 @@ impl<'a> Default for DirectoryConfig<'a> {
|
|||||||
use_logical_path: true,
|
use_logical_path: true,
|
||||||
substitutions: IndexMap::new(),
|
substitutions: IndexMap::new(),
|
||||||
format: "[$path]($style)[$read_only]($read_only_style) ",
|
format: "[$path]($style)[$read_only]($read_only_style) ",
|
||||||
repo_root_format: "[$before_root_path]($style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ",
|
repo_root_format: "[$before_root_path]($before_repo_root_style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) ",
|
||||||
style: "cyan bold",
|
style: "cyan bold",
|
||||||
repo_root_style: None,
|
repo_root_style: None,
|
||||||
|
before_repo_root_style: None,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
read_only: "🔒",
|
read_only: "🔒",
|
||||||
read_only_style: "red",
|
read_only_style: "red",
|
||||||
|
@ -137,6 +137,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
config.repo_root_format
|
config.repo_root_format
|
||||||
};
|
};
|
||||||
let repo_root_style = config.repo_root_style.unwrap_or(config.style);
|
let repo_root_style = config.repo_root_style.unwrap_or(config.style);
|
||||||
|
let before_repo_root_style = config.before_repo_root_style.unwrap_or(config.style);
|
||||||
|
|
||||||
let parsed = StringFormatter::new(display_format).and_then(|formatter| {
|
let parsed = StringFormatter::new(display_format).and_then(|formatter| {
|
||||||
formatter
|
formatter
|
||||||
@ -144,6 +145,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
"style" => Some(Ok(config.style)),
|
"style" => Some(Ok(config.style)),
|
||||||
"read_only_style" => Some(Ok(config.read_only_style)),
|
"read_only_style" => Some(Ok(config.read_only_style)),
|
||||||
"repo_root_style" => Some(Ok(repo_root_style)),
|
"repo_root_style" => Some(Ok(repo_root_style)),
|
||||||
|
"before_repo_root_style" => Some(Ok(before_repo_root_style)),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.map(|variable| match variable {
|
.map(|variable| match variable {
|
||||||
@ -1694,12 +1696,14 @@ mod tests {
|
|||||||
truncation_symbol = "…/"
|
truncation_symbol = "…/"
|
||||||
truncate_to_repo = false
|
truncate_to_repo = false
|
||||||
repo_root_style = "green"
|
repo_root_style = "green"
|
||||||
|
before_repo_root_style = "blue"
|
||||||
})
|
})
|
||||||
.path(dir)
|
.path(dir)
|
||||||
.collect();
|
.collect();
|
||||||
let expected = Some(format!(
|
let expected = Some(format!(
|
||||||
"{}{}repo{} ",
|
"{}{}{}repo{} ",
|
||||||
Color::Cyan.bold().paint(convert_path_sep("…/above/")),
|
Color::Blue.prefix(),
|
||||||
|
convert_path_sep("…/above/"),
|
||||||
Color::Green.prefix(),
|
Color::Green.prefix(),
|
||||||
Color::Cyan.bold().paint(convert_path_sep("/src/sub/path"))
|
Color::Cyan.bold().paint(convert_path_sep("/src/sub/path"))
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user