ConEmu and cmder fix for saving current working directory

ConEmu and tools built on it like cmder are awesome for Windows development. I can’t see myself ever going back to conhost.exe with its lack of color, unicode-support, buffered-scrolling, tabs, configuration, sane hotkeys… ConEmu does come with a set of annoyances though.

The biggest ConEmu annoyance for me is it not properly persisting the current working directory in Git Bash. Long story short you need to add this snippet to your .bashrc.

#ConEmu Integration
if [[ -n "${ConEmuPID}" ]]; then
#For WSL and cygwin/msys connector (which ConEmu will use for Git bash). It
#sends an operating system command (OSC) to cygwin/msys connector to update the
#cwd on PS1 print (the \$PWD in the below string, \w will not work).

ConEmu by default does not know when Git Bash changes its working directory. This breaks features like tab cloning (hotkey WinS), %CD% in tasks, and workspace persistence. To notify ConEmu of changes, you have to send an operating system command (OSC) using special control characters. The ConEmu documentation does describe how to set this up but I still found it buggy. After extensive testing, I found that only paths that contain the ~ character break it and submitted a bug for it. Using the above snippet I created implements the OSC described in the documentation and also fixes the bug.

This fixes tab cloning, %CD% in tasks, and workspace persistence for non-cmd shells. You can now use all of those features and do nifty things like using the same directory when opening a new task no matter what shell. All you need to do is add /dir %CD% to your “Task Parameters” so that when ConEmu starts that task, all commands will have %CD% as their current working directory.

Powered by Hexo Logo Fursona by TFOTR

Compiling Blender as a Python Module for Windows 10 x64 using Visual Studio

Using: blenderv2.78 pythonv3.4 or v3.5

If you want to do unit tests of Blender Python code, it might be to your benefit to not startup Blender every time you want to run them but to just import Blender as a Python module and run them from the command line. This is especially important/nice if you want to automate your tests. Note, before you jump in, if you just need mathutils you can get that separately here.

Luckily, Blender’s build has a nifty feature by which you can compile it as a Python module and then import blender from Python…

import bpy #Starts up Blender as Python module
from mathutils import Vector #Import a Blender specific library

Unfortunately for me, all of the tutorials I found were not geared toward the target I was looking for: Blender 2.78, Windows 10 x64, Microsoft Visual Studio Express 2013+, and Python 3.5. After a couple days I was able to get it all building and working with this tool chain and it should work just as well for x86, a different Python version, or a different MSVS version.