12

I want to assign a keyboard short cut within ConEmu that will open a new tab, in the same directory as the current tab is within.

So something like:

-new_console:d:[<pwd>]%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i

where [<pwd>] runs pwd or grabs the $PWD environment variable. Or any command that would get the current working directory.

--UPDATE---

Currently I have a bash script set up:

winpwda()
{
    pwd | sed -e 's/\//\\/g ' | sed 's/^.//' | sed 's/^c/C:/g'
}
nc()
{
 ConEmu.exe -new_console:d:"$(winpwda)" "%ProgramFiles(x86)%\Git\bin\sh.exe" &
}

running "nc" will now open a new window with a git bash ConEmu in the current directory. Annoyingly if I use "cmd" instead of "ConEmu.exe" it successfully opens it in a new tab instead of a new window. Also not sure how i can assign a bash argument as a keyboard short cut...

  • ConEmu.exe? It doesn't have switch -new_console. You must use proper executable to get proper result! Ex. ConEmuC -c bash.exe ... – Maximus Jul 20 '15 at 19:13
11

ConEmu's docs clearly state what user shall to configure.

For bash user has to add to bash profile

PROMPT_COMMAND='ConEmuC -StoreCWD'

And set up a call of Shell function in the Keys&Macros. Example assumes you have {Git bash} task.

Shell("new_console", "{Git bash}", "", "%CD%")
| improve this answer | |
  • Thank you for the advice, I was definitely on the wrong track, I was looking at "Startup->Tasks->HotKey". So I assigned "Shell("new_console", "{Git bash}", "", "%CD%")" as a macro and added PROMPT_COMMAND to my bashrc but it fails with "directory name is invalid" %CD% – chrispepper1989 Jul 20 '15 at 12:37
  • Also "PROMPT_COMMAND='ConEmuC -StoreCWD'" throws this error: Parsing command line failed (/C argument not found): "c:\Program Files (x86)\EliteTools\ConEmuPack.140812\ConEmu\ConEmuC.exe" -StoreCWD – chrispepper1989 Jul 20 '15 at 12:44
  • Really? Version from what year you are using? – Maximus Jul 20 '15 at 17:03
  • I also needed to put ``` if [ -n "${ConEmuWorkDir}" ]; then cd "$ConEmuWorkDir" fi ``` to my .bashrc, see tips here. – Borek Bernard Sep 27 '17 at 19:20

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.