summaryrefslogtreecommitdiffstats
path: root/src/modules/aws.rs
diff options
context:
space:
mode:
authorThomas O'Donnell <andytom@users.noreply.github.com>2019-09-26 04:55:47 +0200
committerKevin Song <chipbuster@users.noreply.github.com>2019-09-25 21:55:47 -0500
commitb050c597081967cbe7135d294f0cf43c2ec7608d (patch)
treef352a022b49ad9fb1b5d5fed1effe549b3e08e2f /src/modules/aws.rs
parent80a9e7b9a638e4e695be8280a9baff3550037111 (diff)
feat: Add AWS module (#419)
Adds a module for displaying the current AWS profile based on the AWS_PROFILE envar.
Diffstat (limited to 'src/modules/aws.rs')
-rw-r--r--src/modules/aws.rs29
1 files changed, 29 insertions, 0 deletions
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<Module<'a>> {
+ 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)
+}