aboutsummaryrefslogtreecommitdiff
path: root/src/venv.rs
blob: 7906abc34ea8c0c1ebb57774fe4ca3d949b47a7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()
}