feat(username): add detect_env_vars as option (#5833)

* Added the option "detect_env_vars" to the `username` module

with the same functionality as in the `hostname` module.

* Fixed logic error and added test to catch it

* build(deps): update dependency vitepress to ^1.0.0-rc.45

* build(deps): update rust crate shadow-rs to 0.27.1

* Added the option "detect_env_vars" to the `username` module

with the same functionality as in the `hostname` module.

* Fixed logic error and added test to catch it

* Removed unused gix import

* Removed unused gix import, again

* Removed unused gix import. Next try

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
Mick Hohmann
2024-03-20 22:47:32 +01:00
committed by GitHub
parent aef1a3f275
commit b8a812b932
4 changed files with 117 additions and 10 deletions
+22 -7
View File
@@ -4357,6 +4357,7 @@ The module will be shown if any of the following conditions are met:
- The current user isn't the same as the one that is logged in
- The user is currently connected as an SSH session
- The variable `show_always` is set to true
- The array `detect_env_vars` contains at least the name of one environment variable, that is set
::: tip
@@ -4368,13 +4369,14 @@ these variables, one workaround is to set one of them with a dummy value.
### Options
| Option | Default | Description |
| ------------- | ----------------------- | ------------------------------------------- |
| `style_root` | `'bold red'` | The style used when the user is root/admin. |
| `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. |
| Option | Default | Description |
| ----------------- | ----------------------- | --------------------------------------------------------- |
| `style_root` | `'bold red'` | The style used when the user is root/admin. |
| `style_user` | `'bold yellow'` | The style used for non-root users. |
| `detect_env_vars` | `[]` | Which environment variable(s) should trigger this module. |
| `format` | `'[$user]($style) in '` | The format for the module. |
| `show_always` | `false` | Always shows the `username` module. |
| `disabled` | `false` | Disables the `username` module. |
### Variables
@@ -4385,6 +4387,8 @@ these variables, one workaround is to set one of them with a dummy value.
### Example
#### Always show the hostname
```toml
# ~/.config/starship.toml
@@ -4396,6 +4400,17 @@ disabled = false
show_always = true
```
#### Hide the hostname in remote tmux sessions
```toml
# ~/.config/starship.toml
[hostname]
ssh_only = false
detect_env_vars = ['!TMUX', 'SSH_CONNECTION']
disabled = false
```
## Vagrant
The `vagrant` module shows the currently installed version of [Vagrant](https://www.vagrantup.com/).