Last active
January 11, 2018 18:10
-
-
Save malfario/3dd3ee6e0c5b0e25d1d0bb039d88b3b7 to your computer and use it in GitHub Desktop.
Cmder virtualenv prompt fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Code based on https://github.com/cmderdev/cmder/issues/1056 | |
-- with modifications to make it actually work (https://github.com/cmderdev/cmder/issues/1056#issuecomment-237403714) | |
--- | |
-- Find out current conda/virtual envs | |
-- @return {false|conda/virtual env name} | |
--- | |
local clink_path_lua_file = clink.get_env('CMDER_ROOT')..'\\vendor\\clink-completions\\modules\\path.lua' | |
dofile(clink_path_lua_file) | |
function get_virtual_env(env_var) | |
env_path = clink.get_env(env_var) | |
if env_path then | |
basen = exports.basename(env_path) | |
return basen | |
end | |
return false | |
end | |
--- | |
-- add virtual env name | |
--- | |
function venv_prompt_filter() | |
-- add in virtual env name | |
local venv = get_virtual_env('VIRTUAL_ENV') | |
if venv then | |
clink.prompt.value = string.gsub(clink.prompt.value, "λ", "["..venv.."] λ") | |
end | |
end | |
clink.prompt.register_filter(venv_prompt_filter, 20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment