Duplicate session in ConEmu

All we need is an easy explanation of the problem, so here it is.

Is there way to “duplicate” session in ConEmu.

I know it’s not possible for every kind of terminal (cmd.exe, powershell, etc),
but I’m most interested in following situation:

  • I’m in cmd.exe console inside ConEmu.
  • By typing Ctrl-T (the shortcut I specified) I am able to open a new console tab, with a new session (cmd.exe).

I want this session to start in the same directory as the first one, original one. I’m feeling that it can be done with %cd% variable or similar, but I couldn’t manage it.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Variant 1

Type in existing cmd prompt

cmd -new_console

and press Enter. Also you may create hotkey/macro for this sequence, for example AppsN –>

print("cmd -new_console\n")

or create cmd-file or doskey alias.


Variant 2

Use menu item Duplicate root.... It will make a copy of your most parent (root) shell of the current tab (where you are calling menu item). Also you may disable duplicate confirmation in the Settings \ Confirmation.


Variant 3

With latest versions (from 140818) you also may use %CD% environment variable within Shell() GuiMacro function. How to set up your shell described here.

Shell("", "cmd", "", "%CD%")

Method 2

The following will do the same thing for PowerShell

ConEmu64.exe /config "shell" /dir "$(pwd)" /cmd powershell -new_console:n

I created the following function that is loaded in my PowerShell profile

function Create-Console($path = $(pwd)) {
  $console = Resolve-Path (join-path (join-path "$env:PROGRAMW6432*" "console*") "ConEmu64*");
  . $console /config "shell" /dir "$path" /cmd powershell -new_console:n
}

Set-Alias sh Create-Console

Then I can execute the following in the console to create a new PowerShell tab in the same directory:

> sh

or create a tab in a different directory with:

> sh c:\some\directory\path

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply