From b050c597081967cbe7135d294f0cf43c2ec7608d Mon Sep 17 00:00:00 2001 From: Thomas O'Donnell Date: Thu, 26 Sep 2019 04:55:47 +0200 Subject: feat: Add AWS module (#419) Adds a module for displaying the current AWS profile based on the AWS_PROFILE envar. --- src/modules/aws.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/modules/aws.rs (limited to 'src/modules/aws.rs') diff --git a/src/modules/aws.rs b/src/modules/aws.rs new file mode 100644 index 000000000..65ca05142 --- /dev/null +++ b/src/modules/aws.rs @@ -0,0 +1,29 @@ +use std::env; + +use ansi_term::Color; + +use super::{Context, Module}; + +pub fn module<'a>(context: &'a Context) -> Option> { + const AWS_CHAR: &str = "☁️ "; + const AWS_PREFIX: &str = "on "; + + let aws_profile = env::var("AWS_PROFILE").ok()?; + if aws_profile.is_empty() { + return None; + } + + let mut module = context.new_module("aws"); + + let module_style = module + .config_value_style("style") + .unwrap_or_else(|| Color::Yellow.bold()); + module.set_style(module_style); + + module.get_prefix().set_value(AWS_PREFIX); + + module.new_segment("symbol", AWS_CHAR); + module.new_segment("profile", &aws_profile); + + Some(module) +} -- cgit v1.2.3