64

I have Cmder for Windows it has default path c:\Users\ username and I want to change it to any other path I like or want. How do I change it ?

Also cmder can replace cmd.exe meaning is it possible to set cmder as default program insted of cmd.exe

cmder image

Dave M
  • 13,138
  • 25
  • 36
  • 47
Mandarr Sant
  • 797
  • 2
  • 6
  • 10
  • 2
    Did you tried to find information in docs? https://conemu.github.io – Maximus Oct 15 '16 at 09:11
  • @ Maximus it is not conemu it is cmder and i tried searching docs but i didnt got it http://cmder.net/ – Mandarr Sant Oct 15 '16 at 11:51
  • 1
    @MandarSant ffs please stop saying this. I have had so many hair pulling experiences with trying to configure conemu with git or the above issue. reading the doc is not enough, because this is not an intended problem ffs – samayo Aug 16 '19 at 23:35
  • 1
    I think it is bizarre that cmder doesn't use standard Linux/Unix terminology. User wants to specify $HOME folder. That should work across all shells available in CMDR. Instead, we have weird terminology "Startup dir". But it is not just a startup dir that user wants, user wants place where command like "cd" will always land. – pauljohn32 Oct 14 '20 at 17:51

5 Answers5

112

As of cmder v1.3.6:

  1. Go to 'settings'

  2. In the settings group 'Startup', click on 'Tasks'

  3. Click the console you want to modify (e.g. cmd::Cmder, cmd::Cmder as Admin, bash::bash etc.)

  4. Click the button that says 'Startup dir...'

  5. Select the directory you want the console to start up in by default

  6. Enjoy

Moustache
  • 1,541
  • 1
  • 10
  • 11
  • 2
    Works for Cmder version 1.3.10 – jdhao Dec 21 '18 at 11:25
  • 1
    Thanks, yes I haven't tested it for lower versions but it should be similar. – Moustache Dec 21 '18 at 15:56
  • 1
    In fact, it is the latest version :) – jdhao Dec 22 '18 at 01:57
  • 1
    Ah yes thanks :) I misread your comment as 1.3.1. – Moustache Dec 22 '18 at 13:04
  • 5
    It should be noted that this solution has side effect that "cmder here" contextual menu does not work anymore. It will always open the startup directory you have set up. See [here](https://github.com/cmderdev/cmder/issues/1735) for more information. sad :( – jdhao Dec 24 '18 at 07:01
  • 1
    sadly this doesn't work – samayo Aug 16 '19 at 23:39
  • 1
    @samayo -- could you clarify in what way it doesn't work for you? – Moustache Aug 18 '19 at 17:59
  • 1
    The change doesn't have any effect. Cmder always starts in its default dir. I finally just created a shortcut and assinged the startup dir to it – samayo Aug 18 '19 at 18:06
  • 1
    Thanks for saving me 10 seconds of my life – software_writer Nov 03 '19 at 03:57
  • 1
    Maybe one important thing to add - to success in step 1 (go into Settings) you need to click "hamburger" icon in bottom-right corner and then choose "Settings...", or you can also click WIN+ALT+P – pbialy Aug 06 '20 at 09:34
  • 1
    still works in cmder v1.3.16 – Natrium Aug 26 '20 at 12:49
  • 4
    cmder v1.3.14. If you chose `{cmd::Cmder as Admin}` you may get the error `*cmd is not recognized as an internal or external command, operable program or batch file.` You will need to rearrange the command in the dialog window that is created for you from `-new_console:d:C:\projects *cmd /k ""%ConEmuDir%\..\init.bat" "` to `*cmd /k ""%ConEmuDir%\..\init.bat" " -new_console:d:C:\projects `. – Cale Sweeney Oct 16 '20 at 16:10
  • This didn't work for me. What did work was this in Settings/Startup/Tasks {cmd::Cmder} (I have cmder in my %USERPROFILE% dir): cmd /k "%ConEmuDir%\..\init.bat" -new_console:d:%USERPROFILE% && cd %USERPROFILE%\directory\other_directory – Tyson Feb 02 '22 at 20:52
11

In the init.bat file in ~/cmder/vendor, before

:: Set home path

add

@cd /d "C:/YOUR_PREFERRED_FOLDER/"
Worthwelle
  • 4,538
  • 11
  • 21
  • 32
hiiambo
  • 329
  • 1
  • 2
  • 5
9
  1. Create a shortcut to cmdr
  2. Edit the shortcut, change the "Start in" path to the desired path
  3. Profit
Patrick Roza
  • 91
  • 1
  • 1
2

For those who none of the above solutions worked (Cmder keeps reverting back to old path), here's what I did to fix it:

  1. Do a text search with Notepad++ in your Cmder directory for C:/OLD_FOLDER/
  2. Replace each found instance with your new directory: C:/YOUR_PREFERRED_FOLDER/.

For me, the issue was in ConEmu.xml which was preventing startup folder changes.

Porter Lyman
  • 121
  • 2
1

In cmder\vendor\init.bat there are these lines:

:: Set home path
if not defined HOME set "HOME=%USERPROFILE%"
%lib_console% debug_output init.bat "Env Var - HOME=%HOME%"

set "initialConfig=%CMDER_ROOT%\config\user_profile.cmd"
if exist "%CMDER_ROOT%\config\user_profile.cmd" (
    REM Create this file and place your own command in there
    %lib_console% debug_output init.bat "Calling - %CMDER_ROOT%\config\user_profile.cmd"
    call "%CMDER_ROOT%\config\user_profile.cmd"
)

So to change your default path for cmd.exe all you need to do is to edit your cmder\config\user_profile.cmd file and add something like this at its end:

if not defined CMDER_HOME set "CMDER_HOME=%HOME%"
cd %CMDER_HOME%

I'd recommend using a specific environment variable like %CMDER_HOME% because if you use the same cmder config on multiple hosts, you can set this environment variable to the appropriate directory on each host and use cmder with the exact same configuration. cmder provides a default value for %HOME%, as you can see above, so that seems to be a safe failback value (you get the same behaviour without that line too, but that's probably because the cd failed; which feels nicer to be avoided).

Also cmder can replace cmd.exe meaning is it possible to set cmder as default program insted of cmd.exe

I'm not sure what you mean by this. cmder is just a console emulator that nicely integrates other terminal emulators into its windows. One of these terminal emulators is cmd.exe. So cmder's purpose isn't really to replace cmd.exe, although most certainly you can just create a new tab in cmder whenever you would otherwise spin up a new cmd window. It would be probably useful to know where and why you'd like to use cmder by default instead of cmd?

  • 1
    I think he wants to make it his default command prompt... there's a registry setting for that. – Dagelf Sep 24 '20 at 12:27