forked from thomasnorris/cmder-powerline-prompt
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpowerline_python_venv.lua
More file actions
35 lines (32 loc) · 935 Bytes
/
powerline_python_venv.lua
File metadata and controls
35 lines (32 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local function get_virtual_env(env_var)
env_path = clink.get_env(env_var)
if env_path then
return env_path
end
return false
end
---
-- add conda env name
---
local function conda_prompt_filter()
-- add in python virtual env name
local python_env = get_virtual_env('CONDA_DEFAULT_ENV')
if python_env then
local venv_short = string.match(python_env, "[^\\/:]+$")
clink.prompt.value = clink.prompt.value.."["..venv_short.."] "
end
end
---
-- add virtual env name
---
local function venv_prompt_filter()
-- add in virtual env name
local venv = get_virtual_env('VIRTUAL_ENV')
if venv then
local venv_short = string.match(venv, "[^\\/:]+$")
clink.prompt.value = clink.prompt.value.."["..venv_short.."] "
end
end
-- register the filters
clink.prompt.register_filter(conda_prompt_filter, 95)
clink.prompt.register_filter(venv_prompt_filter, 95)