feat: Implement the prompt module for time (#138)

Add a module which displays the current time in a format requested by
the user. Disabled by default.
This commit is contained in:
John Letey
2019-09-10 18:54:40 +01:00
committed by Kevin Song
parent 7d02f718c8
commit f9a4514045
9 changed files with 207 additions and 1 deletions
+33
View File
@@ -96,6 +96,7 @@ default_prompt_order = [
"cmd_duration",
"line_break",
"jobs",
"time",
"battery",
"character",
]
@@ -603,6 +604,38 @@ The module will be shown if any of the following conditions are met:
symbol = "⚙️ "
```
## Time
The `time` module shows the current **local** time.
The `format` configuration value is used by the [`chrono`](https://crates.io/crates/chrono) crate to control how the time is displayed. Take a look [at the chrono strftime docs](https://docs.rs/chrono/0.4.7/chrono/format/strftime/index.html) to see what options are available.
::: tip
This module is disabled by default.
To enable it, set `disabled` to `false` in your configuration file.
:::
### Options
| Variable | Default | Description |
| ---------- | ------------- | ------------------------------------------------------------------------------------------------------------------- |
| `12hr` | `false` | Enables 12 hour formatting |
| `format` | see below | The [chrono format string](https://docs.rs/chrono/0.4.7/chrono/format/strftime/index.html) used to format the time. |
| `style` | `bold yellow` | The style for the module time |
| `disabled` | `true` | Disables the `time` module. |
If `12hr` is `true`, then `format` defaults to `"%r"`. Otherwise, it defaults to `"%T"`.
Manually setting `format` will override the `12hr` setting.
### Example
```toml
# ~/.config/starship.toml
[time]
disabled = false
format = "🕙[ %T ]"
```
## Username
The `username` module shows active user's username.