aboutsummaryrefslogtreecommitdiff
path: root/src/venv.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/venv.rs')
-rw-r--r--src/venv.rs19
1 files changed, 19 insertions, 0 deletions
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 @@
1use std::env;
2use colored::*;
3use std::path::Path;
4
5pub fn get_name() -> colored::ColoredString {
6 match env::var("VIRTUAL_ENV") {
7 Ok(venv_path) => {
8 let venv_name = Path::new(&venv_path[..]).file_name();
9 if let Some(name) = venv_name {
10 if let Some(valid_name) = name.to_str() {
11 return format!("({})", valid_name).bright_black();
12 }
13 }
14 }
15 Err(_) => {}
16 }
17 return "".white()
18}
19