Skip to content

# cmderdev/cmder

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
opened this issue Dec 18, 2013 · 39 comments

## Comments

### hyperknot 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 commented Dec 19, 2013

 In the init.bat before :: Set home path add @cd /d "C:/YOUR_PREFERRED_FOLDER/"
Author

### hyperknot 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).
Contributor

### austinwagner 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.
Contributor

### bdukes 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)
Contributor

### austinwagner 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?
Contributor

### bdukes 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.
Contributor

### austinwagner commented Dec 20, 2013

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

### hyperknot 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.
Contributor

### austinwagner 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.
Author

### hyperknot 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

### kkorus 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 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 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 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 commented Sep 28, 2015

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

### JamoCA 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 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
Contributor

### jankatins commented Feb 16, 2016

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

### remcoros 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 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 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 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 commented Sep 8, 2016

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

Closed

### ravindrapalli33 commented Oct 26, 2016 • edited

 Another Method USING GUI RUN cmder Right click on the tab bar and go to settings Select Tasks under Start UP On the right side -> select Predefined Tasks(anyone) -> In my case I'm using cmd: Cmder After selecting click on Startup dir... at the bottom of the window. Browse the directory and click OK Save settings Now open new console or close and open cmder.

### saeed3e commented Dec 11, 2016 • edited

 Addition on @ravindrapalli33 comment: And also make sure put/write file path after default cmder settings, as shown in attached image.

### Artaches commented May 7, 2017

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

Closed

### wujohns commented Jun 20, 2017 • edited

 @saeed3e can‘t help anymore，It not work

### syon 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% In case of opening Cmder.exe from shortcuts, you can set the path in arg its property. Now it works for me, I hope this will help.

Closed

### froston commented Dec 6, 2017

 This worked for me ... in /cmder/vendor/init.bat change pushd "%USERPROFILE%" to pushd "%CD%"

### johnkors commented Dec 12, 2017 • edited

 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 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

Closed

### taekout commented Feb 7, 2018 • edited

 -1. Go to setting. (Right click on title bar of the window) --> Click Settings. -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) In my case, I use "set CMDER_START=%USERPROFILE%\cmder_script_folder

### BXMurphy commented Feb 10, 2018 • edited

 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 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.

Closed

Open

### Akiq2016 referenced this issue Jul 29, 2018

Open

#### my-apps #16

0 of 21 tasks complete

### arfmach 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 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%
Contributor

### daxgames commented Dec 13, 2018 • edited

 @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
Contributor

### daxgames 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 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\"" 
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.