mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-12-26 19:40:20 +00:00
feat: Add prefix config to directory module (#642)
This commit is contained in:
parent
9f574eaabd
commit
dee25c7b35
@ -327,6 +327,7 @@ it would have been `nixpkgs/pkgs`.
|
|||||||
| ------------------- | ------------- | -------------------------------------------------------------------------------- |
|
| ------------------- | ------------- | -------------------------------------------------------------------------------- |
|
||||||
| `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. |
|
||||||
|
| `prefix` | `"in "` | Prefix to display immediately before the directory. |
|
||||||
| `style` | `"bold cyan"` | The style for the module. |
|
| `style` | `"bold cyan"` | The style for the module. |
|
||||||
| `disabled` | `false` | Disables the `directory` module. |
|
| `disabled` | `false` | Disables the `directory` module. |
|
||||||
|
|
||||||
|
@ -303,6 +303,7 @@ For example, given `~/Dev/Nix/nixpkgs/pkgs` where `nixpkgs` is the repo root, an
|
|||||||
| ------------------- | ------------- | -------------------------------------------------------------------------------- |
|
| ------------------- | ------------- | -------------------------------------------------------------------------------- |
|
||||||
| `truncation_length` | `3` | Die Anzahl der übergeordneten Ordner, die angezeigt werden. |
|
| `truncation_length` | `3` | Die Anzahl der übergeordneten Ordner, die angezeigt werden. |
|
||||||
| `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. |
|
||||||
|
| `prefix` | `"in "` | Prefix to display immediately before the directory. |
|
||||||
| `style` | `"bold cyan"` | Stil für dieses Modul. |
|
| `style` | `"bold cyan"` | Stil für dieses Modul. |
|
||||||
| `disabled` | `false` | Deaktiviert das `directory`-Modul. |
|
| `disabled` | `false` | Deaktiviert das `directory`-Modul. |
|
||||||
|
|
||||||
|
@ -303,6 +303,7 @@ For example, given `~/Dev/Nix/nixpkgs/pkgs` where `nixpkgs` is the repo root, an
|
|||||||
| ------------------- | ------------- | -------------------------------------------------------------------------------- |
|
| ------------------- | ------------- | -------------------------------------------------------------------------------- |
|
||||||
| `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. |
|
||||||
|
| `prefix` | `"in "` | Prefix to display immediately before the directory. |
|
||||||
| `style` | `"bold cyan"` | The style for the module. |
|
| `style` | `"bold cyan"` | The style for the module. |
|
||||||
| `disabled` | `false` | Disables the `directory` module. |
|
| `disabled` | `false` | Disables the `directory` module. |
|
||||||
|
|
||||||
|
@ -304,6 +304,7 @@ fishスタイルのpwdオプションを使用すると、切り捨てられた
|
|||||||
| ------------------- | ------------- | ----------------------------- |
|
| ------------------- | ------------- | ----------------------------- |
|
||||||
| `truncation_length` | `3` | 現在のディレクトリを切り捨てる親フォルダーの数です。 |
|
| `truncation_length` | `3` | 現在のディレクトリを切り捨てる親フォルダーの数です。 |
|
||||||
| `truncate_to_repo` | `true` | 現在いるgitリポジトリのルートに切り捨てるかどうかです。 |
|
| `truncate_to_repo` | `true` | 現在いるgitリポジトリのルートに切り捨てるかどうかです。 |
|
||||||
|
| `prefix` | `"in "` | Prefix to display immediately before the directory. |
|
||||||
| `style` | `"bold cyan"` | モジュールのスタイルです。 |
|
| `style` | `"bold cyan"` | モジュールのスタイルです。 |
|
||||||
| `disabled` | `false` | `directory`モジュールを無効にします。 |
|
| `disabled` | `false` | `directory`モジュールを無効にします。 |
|
||||||
|
|
||||||
|
@ -303,6 +303,7 @@ style = "dimmed green"
|
|||||||
| ------------------- | ------------- | ---------------------------------------------------------------------------- |
|
| ------------------- | ------------- | ---------------------------------------------------------------------------- |
|
||||||
| `truncation_length` | `3` | Количество родительских папок, к которым должен быть усечен текущий каталог. |
|
| `truncation_length` | `3` | Количество родительских папок, к которым должен быть усечен текущий каталог. |
|
||||||
| `truncate_to_repo` | `true` | Следует или нет обрезать до корня репозитория git, в котором вы находитесь. |
|
| `truncate_to_repo` | `true` | Следует или нет обрезать до корня репозитория git, в котором вы находитесь. |
|
||||||
|
| `prefix` | `"in "` | Prefix to display immediately before the directory. |
|
||||||
| `style` | `"bold cyan"` | Стиль модуля. |
|
| `style` | `"bold cyan"` | Стиль модуля. |
|
||||||
| `disabled` | `false` | Отключает модуль `directory`. |
|
| `disabled` | `false` | Отключает модуль `directory`. |
|
||||||
|
|
||||||
|
@ -303,6 +303,7 @@ For example, given `~/Dev/Nix/nixpkgs/pkgs` where `nixpkgs` is the repo root, an
|
|||||||
| ------------------- | ------------- | -------------------------------------------------------------------------------- |
|
| ------------------- | ------------- | -------------------------------------------------------------------------------- |
|
||||||
| `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. |
|
||||||
|
| `prefix` | `"in "` | Prefix to display immediately before the directory. |
|
||||||
| `style` | `"bold cyan"` | The style for the module. |
|
| `style` | `"bold cyan"` | The style for the module. |
|
||||||
| `disabled` | `false` | Disables the `directory` module. |
|
| `disabled` | `false` | Disables the `directory` module. |
|
||||||
|
|
||||||
|
@ -303,6 +303,7 @@ style = "dimmed green"
|
|||||||
| ------------------- | ------------- | ------------------------- |
|
| ------------------- | ------------- | ------------------------- |
|
||||||
| `truncation_length` | `3` | 到達現在資料夾的路徑中,要被裁減掉的資料夾數目。 |
|
| `truncation_length` | `3` | 到達現在資料夾的路徑中,要被裁減掉的資料夾數目。 |
|
||||||
| `truncate_to_repo` | `true` | 是否要裁減到你現在所在的 git 儲存庫的根目錄。 |
|
| `truncate_to_repo` | `true` | 是否要裁減到你現在所在的 git 儲存庫的根目錄。 |
|
||||||
|
| `prefix` | `"in "` | Prefix to display immediately before the directory. |
|
||||||
| `style` | `"bold cyan"` | 這個模組的風格。 |
|
| `style` | `"bold cyan"` | 這個模組的風格。 |
|
||||||
| `disabled` | `false` | 停用 `directory` 模組。 |
|
| `disabled` | `false` | 停用 `directory` 模組。 |
|
||||||
|
|
||||||
|
@ -4,22 +4,24 @@ use ansi_term::{Color, Style};
|
|||||||
use starship_module_config_derive::ModuleConfig;
|
use starship_module_config_derive::ModuleConfig;
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig)]
|
#[derive(Clone, ModuleConfig)]
|
||||||
pub struct DirectoryConfig {
|
pub struct DirectoryConfig<'a> {
|
||||||
pub truncation_length: i64,
|
pub truncation_length: i64,
|
||||||
pub truncate_to_repo: bool,
|
pub truncate_to_repo: bool,
|
||||||
pub fish_style_pwd_dir_length: i64,
|
pub fish_style_pwd_dir_length: i64,
|
||||||
pub use_logical_path: bool,
|
pub use_logical_path: bool,
|
||||||
|
pub prefix: &'a str,
|
||||||
pub style: Style,
|
pub style: Style,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> RootModuleConfig<'a> for DirectoryConfig {
|
impl<'a> RootModuleConfig<'a> for DirectoryConfig<'a> {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
DirectoryConfig {
|
DirectoryConfig {
|
||||||
truncation_length: 3,
|
truncation_length: 3,
|
||||||
truncate_to_repo: true,
|
truncate_to_repo: true,
|
||||||
fish_style_pwd_dir_length: 0,
|
fish_style_pwd_dir_length: 0,
|
||||||
use_logical_path: true,
|
use_logical_path: true,
|
||||||
|
prefix: "in ",
|
||||||
style: Color::Cyan.bold(),
|
style: Color::Cyan.bold(),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
module.get_prefix().set_value("in ");
|
module.get_prefix().set_value(config.prefix);
|
||||||
|
|
||||||
Some(module)
|
Some(module)
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,22 @@ fn root_directory() -> io::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_prefix() -> io::Result<()> {
|
||||||
|
let output = common::render_module("directory")
|
||||||
|
.arg("--path=/")
|
||||||
|
.use_config(toml::toml! {
|
||||||
|
[directory]
|
||||||
|
prefix = "sample "
|
||||||
|
})
|
||||||
|
.output()?;
|
||||||
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
|
let expected = format!("sample {} ", Color::Cyan.bold().paint("/"));
|
||||||
|
assert_eq!(expected, actual);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
fn directory_in_root() -> io::Result<()> {
|
fn directory_in_root() -> io::Result<()> {
|
||||||
|
Loading…
Reference in New Issue
Block a user