Cmder: Using the context menu "Cmder Here" should create a new tab (if there's existing terminal) instead of creating a new window

Created on 6 Feb 2018  Â·  13Comments  Â·  Source: cmderdev/cmder

Hello mates :)

Do we have an already existing way to enable this:

  1. Say, I already have an existing CMDER window
  2. I go to D:/somewhere/directory, Right click -> Cmder Here
  3. I wish that the CMDER terminal that will open to go to the already existing window as a new tab (only if there's already existing window, if none, create a new one)

Is this possible? Because my screen is clustered with too many terminal :(

Regards,

Most helpful comment

@GreatFireWall Since it may be a bit confusing, I'll explain in detail:

  • When you download the Cmder .zip file, it will contain a file with this name: Cmder.exe
    This is called the cmder launcher and it's used in Cmder to open a terminal.

  • One of the things that the launcher do is registering the context menu for windows.
    How does it do it? By running the .exe file with the switch: cmder.exe /register.
    You can type it _in a terminal_ while you're in the cmder directory (e.g. C:\appscmder)

    So, if you execute the switch that I mentioned above, then Cmder will install the context menu.

  • Now, we get to the part that @daxgames said. In cmder version 1.3.11 (and above), a new switch has been added to the launcher, that allows you to register Cmder with the _single instance_ windows enabled:

    cmder.exe /register /single
    

    What does that mean? well, the /single switch means that any new cmder terminals will open _in a new tab_ instead of a new window.

NOTE 1: You can omit the .exe extension (and any other path extensions) in Windows, hence why @daxgames wrote cmder /register /single.

NOTE 2: To use this, you must update to the latest version of Cmder (which is 1.3.11 as of writing this).

I hope this helps! :)

All 13 comments

Since this issue is related to how ConEmu works, a modification based on this would work (I use a variation of that myself).

The question is, whether the moderators approve of changing the default behavior in favor of tabs.

Personally I think using tabs is a much better solution, and a window per context menu is pointless.

@DRSDavidSoft Can you explain a little more how you got this working?

@mew1033 Cmder launches ConEmu by calling it from the Cmder.exe binary.

You'll have to either compile Cmder.exe with this option built it, or modifying the Registry key for the context menu to run ConEmu with the switch directly.

I went with the latter at the time of writing my comment.


@daxgames Could you add this option to the launcher code?
e.g. Cmder.exe /newtab %v could be used to open a new tab in ConEmu.

@DRSDavidSoft Sorry to bother you with this, but I am really not versed in dealing with registry files, I was hoping you would have a sample of what the registry key should look like with this modification?

@mew1033 Cmder launches ConEmu by calling it from the Cmder.exe binary.

You'll have to either compile Cmder.exe with this option built it, or modifying the Registry key for the context menu to run ConEmu with the switch directly.

I went with the latter at the time of writing my comment.

@daxgames Could you add this option to the launcher code?
e.g. Cmder.exe /newtab %v could be used to open a new tab in ConEmu.

Just use latest cmder 1.3.11 and register with cmder /register /single. Works for me to open a new tab in an existing window.

@daxgames Can you tell me the step by step ?

Read the above post

@GreatFireWall Since it may be a bit confusing, I'll explain in detail:

  • When you download the Cmder .zip file, it will contain a file with this name: Cmder.exe
    This is called the cmder launcher and it's used in Cmder to open a terminal.

  • One of the things that the launcher do is registering the context menu for windows.
    How does it do it? By running the .exe file with the switch: cmder.exe /register.
    You can type it _in a terminal_ while you're in the cmder directory (e.g. C:\appscmder)

    So, if you execute the switch that I mentioned above, then Cmder will install the context menu.

  • Now, we get to the part that @daxgames said. In cmder version 1.3.11 (and above), a new switch has been added to the launcher, that allows you to register Cmder with the _single instance_ windows enabled:

    cmder.exe /register /single
    

    What does that mean? well, the /single switch means that any new cmder terminals will open _in a new tab_ instead of a new window.

NOTE 1: You can omit the .exe extension (and any other path extensions) in Windows, hence why @daxgames wrote cmder /register /single.

NOTE 2: To use this, you must update to the latest version of Cmder (which is 1.3.11 as of writing this).

I hope this helps! :)

@DRSDavidSoft Thank you ! Solved !

@GreatFireWall You're welcome, I'm happy to help :)

A couple of more notes:

  • This update was made in pull request #1982.
  • All it does is to pass the /single switch to ConEmu (note: that is what is used as for terminal emulator@)

You can read more about what the switch actually does in ConEmu here:
https://conemu.github.io/en/ConEmuArgs.html

By the way, How can I do Cmder Here as Administrator ?

@GreatFireWall

  1. Do you want to have one Cmder Here that opens as administrator, or to have two options like Cmder Here and Cmder Here as Administrator?

  2. In any case, I suggest to use csudo instead of always starting in administrator mode. For example, type csudo notepad.exe, csudo nano.exe, etc. when you're in Cmder window to run an executable (such as notepad.exe and nano.exe) as administrator.

    You can even get a new Cmder as administrator window, by running csudo cmder. This only works if you're on the latest version, and have added [cmder_root] to your %PATH%.

  3. If you want to _always_ start Cmder as administrator, the -new_console:a conemu switch should be used (the a stands for administrator).

    I'm not sure how it should be handled -- but it should either be included in the cmder.exe launcher code, or by modifying the default ConEmu settings.

  4. Additionally, using the windows' UAC elevation would also do the trick, there are several programs available that can elevate the executable.


P.S. To see how your context menu is set-up, go to here (Win + R → regedit.exe):

HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder

From the toolbar, go to File → Export and save the file (e.g. my_cmder.reg).

Then attach it to your comment (by dragging and dropping it), so I can see how your current Cmder context menu is set-up.

@DRSDavidSoft Thanks for your detail guide.

Yes, I want to have Cmder Here and Cmder Here as Administrator both.

Currently, I use cmder.exe /register /single register for Cmder Here, so I want to make Cmder Here as Administrator single also. Is this possible ?

This is my HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder:

image
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vincentntang picture vincentntang  Â·  3Comments

justinmchase picture justinmchase  Â·  3Comments

danwellman picture danwellman  Â·  3Comments

luisrudge picture luisrudge  Â·  3Comments

sathishsoundharajan picture sathishsoundharajan  Â·  3Comments