python - ConEmu: Run command in open Tab?

07
2014-07
  • tim

    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

  • Answers
  • tim

    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!


  • Related Question

    command line - How do you configure ConEmu to run cmd.exe as an Administrator from an Explorer integration?
  • bentayloruk

    I am trying to add a ConEmu Here - Explorer context menu integration entry for the Visual Studio 2012 command prompt. I want the shortcut to Run as Administrator. I am not sure of the right way to do this in ConEmu.

    I am using the following Command (which works but obviously not as Admin):

    cmd.exe /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"" x86
    

    What is the correct way to configure ConEmu to run this as Administrator? If there is not a correct way, how should I adjust the command to make this work?


  • Related Answers
  • Maximus

    Add the following switch at the end of your command

    -new_console:a