2

I'm using ConEmu (which is already open for the task in this question) with running ipython. Now I want to run a command from a second programm (namely notepad++) to make my edited python script run within the conemu/ipython environment.

I'd like to use the magic ipython function %run blaa.py so I'm looking for a command to simply paste a text into conemu where the actual cursor stands and run it (press enter).

I tried via Windows->Run (Ctrl+R) using:

conemu.exe /cmd "%run bla.py" -cur_console

but that does open a new tab in conemu and pasting it in there. But Id like to have it within ipython to run within the actual environment, i.e. the same should happen as if I would type "%run bla.py" within ipython myself manually.

Any ideas? Thanks

  • 1
    Have you read about GuiMacro? – Maximus Jun 13 '14 at 11:44
  • No I always tried to inject something or do it via command line interface. But I'll have a look straight away, thanks for the hint, let's see what I can do with it :) – tim Jun 13 '14 at 11:48
  • COuldnt really figure out how this could help me. Do have another tip about how to use it in this case? :) Thanks!!!! – tim Jun 13 '14 at 17:44
  • @Maximus: Ok I read a lot about it. The documentation is not very verbose so it was very tough to figure it out. I have now the following: C:\Program Files (x86)\ConEmu\ConEmu\ConEmuC.exe -GuiMacro:0 print("%run process.py"); unfortunately that doesn't automatically execute the line within ConEmu/IPython. I tried to add ` -GuiMacro:0 keys("{Enter}")` or ; keys("{Enter}") to that line to execute the statement "%run process.py" within ConEmu, but that doesn't press enter within ConEmu. Any ideas? Thanks a lot – tim Jun 13 '14 at 19:14
  • Finally figured it out after hours. Answer posted below. – tim Jun 13 '14 at 19:28
2

Well, after the hint of "GuiMacro" from Maximus and a LOT OF searching, reading and thinking about it, I finally figured it out.

When I now run via Windows->Run (Ctrl+R) the following command:

C:\Program Files (x86)\ConEmu\ConEmu\ConEmuC.exe -GuiMacro:0 print("%run myfile.py\n");

then the code %run myfile.py is pasted into the IPython Tab in ConEmu and executed \n emulates a Enter-keystroke.

Now I can use this from notepad++ via Run (F5) to run the following:

"C:\Program Files (x86)\ConEmu\ConEmu\ConEmuC.exe" -GuiMacro:0 print("%run '$(FULL_CURRENT_PATH)'\n");

assign a shortcut to it (I have Ctrl+Alt+Q) and vice versa -> You can execute your python-file within the open IPython/ConEmu-Session (instead of executing it in usual cmd). SO AWESOME!!!!!! I hope that helps someone in the future!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.