diff options
author | Akshay <[email protected]> | 2020-08-18 10:24:00 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-08-18 10:24:00 +0100 |
commit | 4b80626122466e8e3ae166d7212d5511412795bc (patch) | |
tree | 42078d16348b6d26320f3eb4ea2b82315ded54d6 | |
parent | fed2691d6045844214fa19b2dbdfe37d299bc90a (diff) |
detect nix-shell env
-rw-r--r-- | src/main.rs | 5 | ||||
-rw-r--r-- | src/venv.rs | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index b839325..1a77759 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -50,12 +50,13 @@ fn pista(zsh: bool) -> String { | |||
50 | ) | 50 | ) |
51 | } else { | 51 | } else { |
52 | format!( | 52 | format!( |
53 | "{cwd} {branch} {status}\n{venv}{pchar} ", | 53 | "{cwd} {branch} {status}\n{venv}{nix}{pchar} ", |
54 | cwd = cwd, | 54 | cwd = cwd, |
55 | branch = branch, | 55 | branch = branch, |
56 | status = status, | 56 | status = status, |
57 | venv = venv, | 57 | venv = venv, |
58 | pchar = prompt_char | 58 | pchar = prompt_char, |
59 | nix = venv::in_nix_shell() | ||
59 | ) | 60 | ) |
60 | } | 61 | } |
61 | } | 62 | } |
diff --git a/src/venv.rs b/src/venv.rs index 7906abc..da6830c 100644 --- a/src/venv.rs +++ b/src/venv.rs | |||
@@ -17,3 +17,16 @@ pub fn get_name() -> colored::ColoredString { | |||
17 | return "".white() | 17 | return "".white() |
18 | } | 18 | } |
19 | 19 | ||
20 | pub fn in_nix_shell() -> colored::ColoredString { | ||
21 | match env::var("IN_NIX_SHELL") { | ||
22 | Ok(p) => { | ||
23 | if p == "pure" { | ||
24 | "(nix) ".green() | ||
25 | } else { | ||
26 | "(nix) ".red() | ||
27 | } | ||
28 | } | ||
29 | _ => return "".white(), | ||
30 | } | ||
31 | } | ||
32 | |||