Fixing a problem with scoping + escaping spaces in path

the script was defining commands with 's:' in it which made it fail every time I was loading saved session.

Also the script only escaped backslashes. I added a line that escapes spaces. Maybe not the best way to do it, but it works.