im trying to write a sublime function that will take the current file and run it in a new shell in ConEmu, Im having some issues with escaping a \t
when I have a path that looks like
c:\ps\test.ps1
the t gets dropped, i've tried to do some things with escaping it but havent had any luck.
here is the sublime function
class ConemuPstestCommand(sublime_plugin.TextCommand):
def run(self, edit):
if self.view.file_name():
if self.view.is_dirty():
self.view.run_command("save")
folder = path.dirname(self.view.file_name())
testFile = path.join(folder, "test.ps1")
if(not (path.exists(testFile))):
testFile = path.join(path.split(folder)[0],"test.ps1")
if(path.exists(testFile)):
testFile = testFile + "\n"
print(testFile)
testFile = re.sub(r'\t', r'\\t', testFile)
#testFile = testFile.translate(str.maketrans({"\t": r"\\\t","\\": r"\\"}))
print(testFile)
subprocess.call([CONEMUC, "-GUIMACRO:0","Task(""{Shells::PowerShell}"")"],startupinfo=si)
#subprocess.call([CONEMUC, "-GUIMACRO:0","Recreate(0,0,0)"],startupinfo=si)
subprocess.call([CONEMUC, "-GUIMACRO:0", "PASTE", "2", testFile], startupinfo=si)
basically the idea is that if you hit F6 in a powershell module it will run the test.ps1 in that folder. based on both of the print(testFile) the output in the sublime console looks correct, when it gets over to powershell the t on test is missing (oddly the \ is still there)
The really odd thing is if i comment out the Task() (new powershell console) line it copies it over correctly in to the current console (same conemu task type)
Im running version 150513 [64] and sublime 3 (3083)
as a simple test, I ran this bit of python code from a a conemu console
import re,subprocess
CONEMUC = "C:\\Program Files\\ConEmu\\ConEmu\\ConEmuC64.exe"
si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
si.wShowWindow = subprocess.SW_HIDE
subprocess.call([CONEMUC, "-GUIMACRO:0","Task(""{Shells::PowerShell}"");context;print(""test"")"],startupinfo=si)
This will start the console fine, but it does not print the text
Also the Python version is Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] on win32
An even simpler test, I started a cmd shell and ran this command
ConEmuC.exe -guimacro task("{Shells::cmd}");context;print("test")
It will report back OK;OK;OK The new shell is opened and test is printed in the console i ran this from. So it looks like context isnt really doing what it should?
I just tried another simple test
ConEmuC.exe -guimacro Create(0,0);context;print("test")
This time it worked correctly. It seems like Task() and Context dont want to work together?
It seems like not really sure if this is something conemu is doing or the sublime/python side of things. any thoughts?
thanks