Conda gives error when doing “source activate” in cmder

So I used Cmder, the rather awesome command lined emulator, instead of cmd.exe or powershell when doing command line development work. I also like powershell a lot but feel much more comfortable with Cmder which has the benefit of support Unix comamnds. Anyways I was having problems with conda in Cmder not “activating” virtual python environments. After looking on stack overflow and git I found some workarounds that ended up not working out well for me. Most of the workarounds focused on starting Cmder and either launching a script to deal with how Cmder and conda deal with the added lambda symbol for example the first solution here That ended up not working for me. Instead, you can do something like this.  Find the file in “YOURPATHTOCMDER\cmder\vendor\clink.lua” and change the function, function set_prompt_filter(), to this:

function set_prompt_filter()
-- orig: $E[1;32;40m$P$S{git}{hg}$S$_$E[1;30;40m{lamb}$S$E[0m
-- color codes: "\x1b[1;37;40m"
cwd = clink.get_cwd()
prompt = "\x1b[1;32;40m{cwd} {git}{hg} \n\x1b[1;30;40m{lamb} \x1b[0m"
new_value = string.gsub(prompt, "{cwd}", cwd)
clink.prompt.value = string.gsub(new_value, "{lamb}", ">>")

You can set other values but >> is more familiar.

Update: Longer blog post on Cmder although it looks like the version of Cmder is a bit older


About ordo tacitus

ordo tacitus
This entry was posted in programming, Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s