diff options
author | NerdyPepper <[email protected]> | 2019-05-20 13:48:12 +0100 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-05-20 13:48:12 +0100 |
commit | f982aa673701bd5084a228ce9caee6941e3d86f1 (patch) | |
tree | daf943b3bbc686e0818dfb697c6ad145a95e2f3f /src/venv.rs | |
parent | af5b620f472ceefc2408f59fdf30b85e92390f7f (diff) |
grand refactor
Diffstat (limited to 'src/venv.rs')
-rw-r--r-- | src/venv.rs | 19 |
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 @@ | |||
1 | use std::env; | ||
2 | use colored::*; | ||
3 | use std::path::Path; | ||
4 | |||
5 | pub 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 | |||