From f982aa673701bd5084a228ce9caee6941e3d86f1 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Mon, 20 May 2019 18:18:12 +0530 Subject: grand refactor --- src/venv.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/venv.rs (limited to 'src/venv.rs') diff --git a/src/venv.rs b/src/venv.rs new file mode 100644 index 0000000..7906abc --- /dev/null +++ b/src/venv.rs @@ -0,0 +1,19 @@ +use std::env; +use colored::*; +use std::path::Path; + +pub fn get_name() -> colored::ColoredString { + match env::var("VIRTUAL_ENV") { + Ok(venv_path) => { + let venv_name = Path::new(&venv_path[..]).file_name(); + if let Some(name) = venv_name { + if let Some(valid_name) = name.to_str() { + return format!("({})", valid_name).bright_black(); + } + } + } + Err(_) => {} + } + return "".white() +} + -- cgit v1.2.3