feat: add a container indicator (#3304)

* test: add mock method for absolute files

Signed-off-by: Harald Hoyer <harald@hoyer.xyz>

* feat(module): add a container indicator module

Adds a container type indicator, if inside a container,
detected via the presence of some marker files.

E.g. inside a podman container entered with `toolbox enter`
the prompt changes to the container name and version.

```
starship on  container_rebased [$!] is 📦 v1.0.0 via 🦀 v1.56.1
❯ toolbox enter

starship on  container_rebased [$!] is 📦 v1.0.0 via 🦀 v1.56.1
⬢ [fedora-toolbox:35] ❯
```

Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
This commit is contained in:
Harald Hoyer
2022-01-21 16:44:46 +01:00
committed by GitHub
parent 0d573ac5ea
commit 4f46411403
11 changed files with 338 additions and 1 deletions
+6
View File
@@ -63,6 +63,10 @@ pub struct Context<'a> {
#[cfg(test)]
pub cmd: HashMap<&'a str, Option<CommandOutput>>,
/// a mock of the root directory
#[cfg(test)]
pub root_dir: tempfile::TempDir,
#[cfg(feature = "battery")]
pub battery_info_provider: &'a (dyn crate::modules::BatteryInfoProvider + Send + Sync),
@@ -155,6 +159,8 @@ impl<'a> Context<'a> {
target,
width,
#[cfg(test)]
root_dir: tempfile::TempDir::new().unwrap(),
#[cfg(test)]
env: HashMap::new(),
#[cfg(test)]
cmd: HashMap::new(),