Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to start in a given directory #91

Closed
hyperknot opened this issue Dec 18, 2013 · 39 comments

Comments

@hyperknot
Copy link

commented Dec 18, 2013

I am trying to integrate cmder into TotalCommander.

I have been using cmd.exe and msysgit integration in with custom keys (F8, F9) to start them in the current directories from Total Commander.

I would like to do it with cmder, but every time it starts in the user's homedir. Is there any way to make cmder start in a given dir?

@seandowney

This comment has been minimized.

Copy link

commented Dec 19, 2013

In the init.bat before

:: Set home path

add

@cd /d "C:/YOUR_PREFERRED_FOLDER/"

@hyperknot

This comment has been minimized.

Copy link
Author

commented Dec 19, 2013

But how do I connect it to either:
a. an external argument for "cmder.bat", like "cmder.bat "C:\my folder""?
b. the current working directory %CD%?

Supporting the current working directory would be good for use cases
when you put cmder in your path, and then you could just start-up cmder
from any cmd / PS / bash you happen to be in.

One idea I have in mind is to add a new variable "setdir" to cmder.bat,
which would be set to %1 if present and %CD% if not.

Later this should somehow be linked to init.bat to actually change the
folder, or maybe conemu.exe supports a param? How is Ctrl + T's "startup
directory for the new processs" is implemented?

On 19/12/2013 12:48, Sean Downey wrote:

In the init.bat before

:: Set home path

add

@cd https://github.com/cd /d "C:/YOUR_PREFERRED_FOLDER/"


Reply to this email directly or view it on GitHub
#91 (comment).

@austinwagner

This comment has been minimized.

Copy link
Contributor

commented Dec 19, 2013

If you're using the latest version, you will have Cmder.exe instead of Cmder.bat. You can pass a path as an argument to start in that directory.

@bdukes

This comment has been minimized.

Copy link
Contributor

commented Dec 19, 2013

Using the v1.1.2 release, I wasn't able to get cmder.exe to do anything with a path as an argument (I tried prepending with /start, which showed up when trying to pass /?, but that didn't help)

@austinwagner

This comment has been minimized.

Copy link
Contributor

commented Dec 20, 2013

@bdukes I've tested on Win 8.1 x64 (not elevated) and Win 7 x64 (elevated) and it starts at the path that I provide. Can you verify that the line @if defined CMDER_START cd /d "%CMDER_START%" is at the end of cmder/vendor/init.bat? If it is, could you also add @echo %CMDER_START% to the end of that script and see what it outputs when you start Cmder?

@bdukes

This comment has been minimized.

Copy link
Contributor

commented Dec 20, 2013

I've changed the configuration to start powershell instead of cmd by default, so it's not running init.bat. I guess I'll need to wait until init.ps1 gets integrated. Thanks.

@austinwagner

This comment has been minimized.

Copy link
Contributor

commented Dec 20, 2013

That would explain it. I forgot about powershell since I don't ever use it.

@hyperknot

This comment has been minimized.

Copy link
Author

commented Dec 21, 2013

OK, this works, although it might still be a good idea to start by default in %CD%, as in Windows I found that the user's default folder is simply not as important as in *nix based systems. Calling cmder from any folder might make sense.

But it definitely works with the first argument.

@austinwagner

This comment has been minimized.

Copy link
Contributor

commented Dec 21, 2013

Actually it probably makes the most sense to just statically link against the CRT. However, the 2013 DLLs do not have to be installed because they are included in the release.

@hyperknot

This comment has been minimized.

Copy link
Author

commented Dec 21, 2013

Sorry for first writing the dll issue it here, I've updated and moved that to a separate issue here:
#93

@hyperknot hyperknot closed this Dec 25, 2013

@kkorus

This comment has been minimized.

Copy link

commented Jul 7, 2015

to add:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Console]
@="Cmder"

[HKEY_CLASSES_ROOT\Directory\shell\Console\command]
@=""D:\Apps\cmder\Cmder.exe" /START "%V""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Console]
@="Cmder"

[HKEY_CLASSES_ROOT\Directory\Background\shell\Console\command]
@=""D:\Apps\cmder\Cmder.exe" /START "%V""

to remove:
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Directory\shell\Console]

[-HKEY_CLASSES_ROOT\Directory\Background\shell\Console]

@JamoCA

This comment has been minimized.

Copy link

commented Sep 18, 2015

So what command line options need to be added in order to launch cmder.exe and have it start in a specified path? I'm using Total Commander too & added a link to the menu bar. I want to open cmder in the currently selected directory and haven't had any success passing different "command" or "parameter" options. Thanks.

I tried this at a DOS prompt and it launches, but doesn't default to the "c:" directory:

c:/utils/cmder/cmder.exe /start "c:\"
@Sergej-Popov

This comment has been minimized.

Copy link

commented Sep 21, 2015

@JamoCA that command works for me, but only if cmder not already running. If instance of cmder is running it will refuse to open new tab in that location. This is annoying as ConEmu doesn't have that problem!

@JamoCA

This comment has been minimized.

Copy link

commented Sep 21, 2015

ok, I guess that makes sense, but it feels more like a limitation. I'm trying to keep cmder running in the tray. It'd be beneficial if there were a parameter to launch a specified path in a new cmder tab; kinda like clicking a URL opens a new tab in an already-running default browser.

@kkorus

This comment has been minimized.

Copy link

commented Sep 28, 2015

@JamoCA Hi, did you figure out how to open new folder as new tab? :)

@JamoCA

This comment has been minimized.

Copy link

commented Oct 6, 2015

Strange. I removed the quotes from a simple path with no spaces (c:) and it works, but "c:" does not.

If I pass a path that has spaces in the directory name (c:\program files), it won't work unless I specifically add quotes ("c:\program files").

Is this a bug? Paths should always work with quotes regardless of whether they have spaces or not, right? Or do I path names need to be parsed to determine if there are spaces and then manually add quotes?

If I untoggle "Settings | Appearance | Single Instance Mode", individual cmder windows will open to the correct directories. If I enable "single instance mode", any new "/start" commands fail... a new cmder tab w/the specified start directory is not opened.

If cmder is running in the tray with no tab open, using DOS to specify new start directory doesn't do anything... unless "single instance" is disabled.

QUESTION: Is it possible to execute cmder.exe with a unique start path and have it open up in a single instance with a new tab?

@kuncevic

This comment has been minimized.

Copy link

commented Feb 16, 2016

Trying to open a directory in new tab cmder /single "path_to_my_dir" not working. Only got new tab opened. Tried also with just simple paths:
cmder /single /start "c:"
cmder /single /dir "c:"
cmder /single "c:"
cmder /single "/c" (cygwin path)
Also tried same without quotes - doesn't matter - just got thing always opening in the same path as previous tab.
With backslash in the end cmder /single "c:\" getting new line started with greater sign
image

@jankatins

This comment has been minimized.

Copy link
Contributor

commented Feb 16, 2016

Please try on of the latest dev builds (in appveyor -> artifacts)

@remcoros

This comment has been minimized.

Copy link

commented Mar 8, 2016

I just downloaded the latest appveyor build (mini). Completely removed 1.2.9 and started with a fresh install.

I changed to 'single instance mode' in settings (and that's the ONLY setting I change).

Still not working properly for me :(

I tried:

Start the first instance using a shortcut on my taskbar (this opens in C:\Users\Remco).

Then (from Win-R):

  • cmder.exe "C:"
    Gives focus to cmder, but nothing happens
  • cmder.exe /start "C:"
    Gives focus to cmder, but nothing happens
  • cmder.exe /single "C:"
    Gives focus to cmder, Opens a new tab, but doesn't change to "C:" (it stays in C:\Users\Remco)
@kuncevic

This comment has been minimized.

Copy link

commented Mar 8, 2016

@remcoros I figure out that in my case actually I had setting under Settings/Startup/Tasks/{Taskname}: d:%USERPROFILE% that tells cmder to open my %USERPROFILE% directory on start by default. By removing that all working fine

@jakubsuchybio

This comment has been minimized.

Copy link

commented Mar 26, 2016

Thanks! Worked for me. When removed the %USERPROFILE% from Tasks in Settings of cmder. Then everytime I start cmder from Total Commander I am at current dir, which I started it from.

@pianoboysai

This comment has been minimized.

Copy link

commented Apr 11, 2016

this is my solution.
open init.bat, and delete this section
"
@if defined CMDER_START (
@cd /d "%CMDER_START%"
) else (
@if "%CD%" == "%CMDER_ROOT%" (
@cd /d "%HOME%"
)
)
"

then set single instance for cmder, finally, add register item:
C:\yourpath\cmder.exe /single "%V"

@eromoe

This comment has been minimized.

Copy link

commented Sep 8, 2016

thanks @kuncevic
All bad is %USERPROFILE% in task , remove that make me open cmder in current directory.

@ravindrapalli33

This comment has been minimized.

Copy link

commented Oct 26, 2016

Another Method USING GUI

  1. RUN cmder
    image
  2. Right click on the tab bar and go to settings
  3. Select Tasks under Start UP
  4. On the right side -> select Predefined Tasks(anyone) -> In my case I'm using cmd: Cmder
  5. After selecting click on Startup dir... at the bottom of the window.
  6. Browse the directory and click OK
  7. Save settings
  8. Now open new console or close and open cmder.
@saeed3e

This comment has been minimized.

Copy link

commented Dec 11, 2016

Addition on @ravindrapalli33 comment:

And also make sure put/write file path after default cmder settings, as shown in attached image.

cmder

@Artaches

This comment has been minimized.

Copy link

commented May 7, 2017

Checkout my answer here: http://stackoverflow.com/questions/31933766/start-up-cmder-conemu-console-in-a-specific-folder/43836978#43836978

Basically, create a shortcut for ConEmu and change the "Start in:" attribute in the shortcut's properties.

@wujohns

This comment has been minimized.

Copy link

commented Jun 20, 2017

@saeed3e can‘t help anymore,It not work

@syon

This comment has been minimized.

Copy link

commented Jun 28, 2017

Here is my settings. This is for "Cmder Here", not for a fixed path.

Using %CMDER_START% instead of %USERPROFILE%.

  • *cmd /k "%ConEmuDir%\..\init.bat" -new_console:d:%USERPROFILE%
  • *cmd /k "%ConEmuDir%\..\init.bat" -new_console:d:%CMDER_START%

cmder-settings-edit

In case of opening Cmder.exe from shortcuts, you can set the path in arg its property.

cmder-property

Now it works for me, I hope this will help.

@froston

This comment has been minimized.

Copy link

commented Dec 6, 2017

This worked for me ...
in /cmder/vendor/init.bat change

pushd "%USERPROFILE%" to pushd "%CD%"

@johnkors

This comment has been minimized.

Copy link

commented Dec 12, 2017

Thanks, @froston . Worked for me as well.

Edit: I'm using init.bat directly thru Visual Studio Code to launch cmder as an integrated terminal.

@Frankstar

This comment has been minimized.

Copy link

commented Dec 20, 2017

@froston THANK YOU! After changing that i can use the -new_console:d:C:\path\to\dir
in combination with the init script for Tasks!

Working Example: cmd /k "%ConEmuDir%\..\init.bat" -new_console:d:C:\choco-packages

Pls fix this Upstream

@taekout

This comment has been minimized.

Copy link

commented Feb 7, 2018

-1. Go to setting. (Right click on title bar of the window) --> Click Settings.

setting

-2. Then in the setting window, on left panel, click [Startup>Environment] then add string in text box on the right.
set CMDER_START=C:\YOUR_PREFERRED_PATH
(See image below)
image

In my case, I use "set CMDER_START=%USERPROFILE%\cmder_script_folder

@BXMurphy

This comment has been minimized.

Copy link

commented Feb 10, 2018

Thank you, @taekout! I followed your instructions as you circled in your image. That worked perfectly. Thanks for taking the time to post screenshots, too!

@vidyanaputranto

This comment has been minimized.

Copy link

commented Apr 18, 2018

I tried all things here but unsuccessful.
In the end I used /START option to be added inside the shortcut and it was working.

@arfmach

This comment has been minimized.

Copy link

commented Oct 24, 2018

The /start command-line option doesn't work for paths with spaces. I've tried to enclose the path in single-quotes and double-quotes, but neither worked.
Obs. I want to use it as "Cmder here" shortcut, so I can't escape spaces with backslash or caret.

@mhamri

This comment has been minimized.

Copy link

commented Dec 13, 2018

go to vendors\init.bat and add this line at top of the file after the @echo off

set CMDER_START=%cd%
@daxgames

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

@mhamri Why? Current cmder will open in the current dir or a command line specified dir IF your tasks are not using legacy config from older versions. You should never edit init.bat

@daxgames

This comment has been minimized.

Copy link
Contributor

commented Dec 13, 2018

@arfmach what you say does not work works fine for me with current cmder versions IF your tasks are not using legacy config from older versions.

@sinancetinkaya

This comment has been minimized.

Copy link

commented Dec 24, 2018

to add:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Console]
@="Cmder"

[HKEY_CLASSES_ROOT\Directory\shell\Console\command]
@=""D:\Apps\cmder\Cmder.exe" /START "%V""

[HKEY_CLASSES_ROOT\Directory\Background\shell\Console]
@="Cmder"

[HKEY_CLASSES_ROOT\Directory\Background\shell\Console\command]
@=""D:\Apps\cmder\Cmder.exe" /START "%V""

to remove:
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Directory\shell\Console]

[-HKEY_CLASSES_ROOT\Directory\Background\shell\Console]

I had to add backslashes to get it to work

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Console]
@="Cmder"

[HKEY_CLASSES_ROOT\Directory\Background\shell\Console\command]
@="\"D:\\depo\\Sistem\\cmder_mini\\Cmder.exe\" /START \"%V\""

[HKEY_CLASSES_ROOT\Directory\shell\Console]
@="Cmder"

[HKEY_CLASSES_ROOT\Directory\shell\Console\command]
@="\"D:\\depo\\Sistem\\cmder_mini\\Cmder.exe\" /START \"%V\""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.