ConEmu - running a script in the startup console

06
2014-04
  • MrSinister13

    I have a script called todo that echoes a todo list to the terminal. I'd like ConEmu to run this every time it starts (thus, in the starting tab). How do I write a task to make it do that? todo is on my path.

  • Answers
  • Maximus

    In fact, your question does not refer to ConEmu, at all. Read your shell manual (you have not eve said what of dozen possible shells you are using). For example, cmd has "/k" switch, PowerShell has "-noexit -command" and so on...

    Possibly related: http://stackoverflow.com/a/13374719/1405560


  • Related Question

    windows - Attach a running console application to a new ConEmu instance
  • Gilles

    I have an already-started console application, under Windows XP. I want to attach it to a different console emulator such as Console2 or ConEmu. This is possible with ConEmu, and it works if I run ConEmu then use its "Attach to" menu entry and select my console application in the list.

    I am now trying to automate this. I want to be able to focus the console application window, press a key, and have it attached to a new instance of ConEmu. I tried to write an AutoHotKey macro to attach the currently focused console application when I press Win+A, but I can't figure out how to use ConEmuC. Here's my attempt:

    #IfWinActive, ahk_class ConsoleWindowClass
    #a::
      WinGet, app_pid, PID
      Run c:\opt\ConEmu-120704\ConEmu.exe /detached, , , conemu_pid
      Run c:\opt\ConEmu-120704\ConEmu\ConEmuC.exe /ATTACH /PID=%app_pid%
      Return
    

    All I get the following error popup:

    Attach to GUI was requested, but there is no console processes!
    
    c:\opt\ConEmu-120704\ConEmu\ConEmuC.exe /ATTACH /PID=7104
    

    Yet if I use the “Attach to” menu entry in the ConEmu instance, the console application gets attached. I need to tick the “alternative mode” checkbox introduced in version 120704, if that's relevant.

    How do I use ConEmuC (or any other method) to attach an existing console application to a new ConEmu instance? Even better, how do I attach an existing instance (if I want a new instance, I can just create it beforehand)? And how do I specify alternative mode?


  • Related Answers
  • Maximus

    Try the following

    #IfWinActive, ahk_class ConsoleWindowClass
    #a::
      WinGet, app_pid, PID
      Run c:\opt\ConEmu-120704\ConEmu\ConEmuC.exe /ATTACH /CONPID=%app_pid%
      Return
    

    Alternative mode: /ATTACH /CONPID=<pid>.

    Starting ConEmu.exe /detached is unnecessary. GUI will be started automatically, if not found.

    UPD. Build 120705. If you want to unconditionally start new ConEmu window, you may add /GHWND=NEW to ConEmuC arguments.