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

New cmder.exe args and shared install capability #1696

Merged
merged 29 commits into from Mar 13, 2018

Conversation

daxgames
Copy link
Member

@daxgames daxgames commented Mar 7, 2018

1.3.6-pre1 (2018-03-01)

The is a redo of #1665 - See the conversation there if you have questions.

Fixed bugs:

  • Fixed Git version check recently added to master.

Updates:

  • Modified Cmder tasks in default Conemu.xml to allow easily adding command line args for init.bat by adding some quotes. This resulted in a ton of misc changes to this file. See Adds below.
  • Reworked cmder.exe command line argument handling to make it more flexible and easily added to.
  • Reworked README.md tables to make them more readable in editors

Implemented enhancements:

  • Append %GIT_INSTALL_ROOT%\mingw32|64 folder to the path if it exists. Thanks: @gucong3000
  • Added cmder.exe command line args documenttion to README.md
  • Added :enhance_path method to vendor\init.bat that modifies the path only if required.
    • To prepend: call :enhance_path "%cmder_root%"
    • to append: call :enhance_path "%cmder_root%" append
  • Added :enhance_path_recursive method to vendor\init.bat that adds a path and all its sub directories to the path if required.
    • Max recurse depth default is '1' configurable using init.bat /max_depth [1-5]. 6+ results in error.
    • To prepend and go 3 levels deep: call :enhance_path "%cmder_root%" 3
    • To append and go 2 levels deep: call :enhance_path "%cmder_root%" 2 append
  • Added ability to init.bat to accept command line args and documented them in README.md. Allows users to change the behaviour of init.bat without editing the file.
Argument Description Default
/c [user cmder root] Enables user bin and config folders for 'Cmder as admin' sessions due to non-shared environment. not set
/d Enables debug output. not set
/git_install_root [file path] User specified Git installation root path. '%CMDER_ROOT%\vendor\Git-for-Windows'
/home [home folder] User specified folder path to set %HOME% environment variable. '%userprofile%'
/max_depth [1-5] Define max recurse depth when adding to the path for %cmder_root%\bin and %cmder_user_bin% 1
/svn_ssh [path to ssh.exe] Define %SVN_SSH% so we can use git svn with ssh svn repositories. '%GIT_INSTALL_ROOT%\bin\ssh.exe'
/user_aliases [file path] File path pointing to user aliases. '%CMDER_ROOT%\config\user-liases.cmd'
/v Enables verbose output. not set
  • Added new cmder.exe /C \<path\> argument
    • To use run Cmder.exe with "/C" command line argument. Example: cmder.exe /C %userprofile%\cmder_config

    • To use run with Cmder as Admin sessions you must specify "/c" command line argument to init.bat in tasks. See README.md for details.

    • Enables shared Cmder install with Non-Portable Individual User Config

    • Supported by all supported shells (cmder, powershell, git bash, and external bash)

    • This will create the following directory structure if it is missing.

      c:\users\[username]\cmder_config
      ├───bin
      └───config
          └───profile.d
      
    • Shell init scripts run in the following order

      1. %cmder_root%\config\profile.d*.[cmd|ps1|sh]
      2. %cmder_root%\config\user-profile.[cmd|ps1|sh]
      3. %userprofile%\cmder_config\config\profile.d*.[cmd|ps1|sh]
      4. %userprofile%\cmder_config\config\user-profile.[cmd|ps1|sh]

@daxgames
Copy link
Member Author

daxgames commented Mar 7, 2018

@cmderdev/trusted-contributors @DRSDavidSoft - This is a new PR based on #1665 because I screwed that branch up somehow trying to rebase for @Stanzilla. Please test the Nightly build of this commit.

@daxgames daxgames force-pushed the init_args_rebased branch 2 times, most recently from 4ad32c0 to bf014df Compare March 7, 2018 23:08
@DRSDavidSoft
Copy link
Contributor

Subscribed again!

@MartiUK MartiUK self-requested a review March 8, 2018 09:45
MartiUK
MartiUK previously requested changes Mar 8, 2018
Copy link
Member

@MartiUK MartiUK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot confirm that %userprofile%\cmder_config is created on first run in my test.

int argCount;

szArgList = CommandLineToArgvW(GetCommandLine(), &argCount);
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why these lines are left in commented out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
cmderOptions.error = true;
}
//}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out brace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unintentional whitespace here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@MartiUK
Copy link
Member

MartiUK commented Mar 8, 2018

@daxgames Ignore me, I didn't specify %userprofile%\cmder_config when running with /C, should there be a default location?

@daxgames
Copy link
Member Author

daxgames commented Mar 8, 2018

@MartiUK I could clean those comments and whitespace up and add a default for. /c. I thought about that after it was done but just wanted it to be done.

@Stanzilla
Copy link
Member

Yeah a default is needed, bit confusing otherwise, could also make it error if nothing gets specified?

@MartiUK
Copy link
Member

MartiUK commented Mar 9, 2018

@Stanzilla @daxgames Well, at the moment cmder does not start at all when running with /C but without an argument.

@Stanzilla
Copy link
Member

yeah, that should throw an error, imo. I hate it when stuff silently dies and I have no idea why (Hint UWP apps HINT)

@daxgames daxgames dismissed MartiUK’s stale review March 10, 2018 20:44

Comments and whites pace cleaned up and default for /c is %userprofile%\cmder_cfg if the next arg is NULL or not an arg beginning in /

@DRSDavidSoft
Copy link
Contributor

@daxgames I can rewrite the C++ argument parsing logic similar to what I did here in my project.

@daxgames
Copy link
Member Author

daxgames commented Mar 10, 2018

@cmderdev/trusted-contributors, @DRSDavidSoft It's done. Comments and whites space is cleaned up and default for /c is %userprofile%\cmder_cfg if the next arg either is NULL or not an arg beginning in /

There may be a better way to do it but this works.

I also found that the handling and backup of the ConEmu.xml config was not working properly and fixed that. No idea how long its been broken.

The following now work in this order:

If %cmder_root%\config\conemu-%computername%.xml exists

  • If Vendored conemu.xml exists:
    • %cmder_root\vendor\conemu-maximus5\ConEmu.xml is copied to %cmder_root%\config\conemu-%computername%.xml to backup any previous session config changes.
  • else:
    • %cmder_root%\config\conemu-%computername%.xml is copied to %cmder_root\vendor\conemu-maximus5\ConEmu.xml

Else If %cmder_root%\config\user-conemu.xml exists

  • If Vendored conemu.xml exists:
    • %cmder_root\vendor\conemu-maximus5\ConEmu.xml is copied to %cmder_root%\config\user-conemu.xml to backup any previous session config changes.
  • Else:
    • %cmder_root%\config\user-conemu.xml is copied to %cmder_root\vendor\conemu-maximus5\ConEmu.xml

Else If Vendored conemu.xml exists:

  • Vendored %cmder_root%\config\conemu.xml is copied to %cmder_root\config\user-ConEmu.xml

Else:

  • Default %cmder_root%\config\conemu.xml is copied to %cmder_root\vendor\conemu-maximus5\ConEmu.xml

@Stanzilla
Copy link
Member

Really happy with this so far 👍

@MartiUK
Copy link
Member

MartiUK commented Mar 13, 2018

Yeah this looks good to me, is there nothing else to add @daxgames?

Copy link
Contributor

@DRSDavidSoft DRSDavidSoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@Stanzilla Stanzilla self-requested a review March 13, 2018 15:36
@MartiUK MartiUK merged commit 997e799 into cmderdev:master Mar 13, 2018
@Stanzilla
Copy link
Member

Grats on shipping! Also have fun with closing all the issues that are now fixed :)

daxgames added a commit to daxgames/cmder that referenced this pull request Mar 13, 2018
@MartiUK: Squashing to avoid adding multiple "fixed" commits

* add args to init.bat

* adding args to cmder launcher

* reworked command line parsing and added a /C [path] arg for individual user config location

* removed unnecessary includes

* make shell init scripts work with CMDER_USER_CONFIG

* update tasks and readme.md

* fix git version check

* readme updates

* add register/unregister back in

* fixed git version again

* removed error if user defines user-aliases store file was not present an init.bat launch

* added enhance_path method to only update path if required

* added enhance_path method to only update path if required

* fixed a path prepend issue in enhance path

* init.bat with args is executed outside cmder/conemu sets cmder_root properly. Thanks @DRSDavidSoft

* fixed enhance path append issue

* implements recursive `/bin` path enhancing.

cmderdev#1624

* added max depth

* changes command line arg to max_depth

* set max_depth default

* readme.md updates

* add back cmder /c [path] arg so it can be used with admin sessions since the env is not shared.

* readme.md updates

* fix /c setting of cmder_user_config

* changelog and readme

* remove bad arg

* fixed command line parsing and updated command line help on error

* Fixed ConEmu.xml file handling so it works again

* Added default user config root location if '/c' is specified and next arg is not another arg
@daxgames daxgames deleted the init_args_rebased branch March 24, 2018 13:56
@wireddown
Copy link

For users that need to run user_profile.ps1 and friends in profile.d for Administrator sessions in Powershell, you cannot use /c [user cmder root] because Powershell sessions aren't created from init.bat, but instead by

*PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression 'Import-Module ''%ConEmuDir%\..\profile.ps1'''"

and ''%ConEmuDir%\..\profile.ps1'' doesn't accept any command line arguments.

Instead, on the Environment panel, set these two variables to match your configuration:

set CMDER_USER_BIN=C:\full\path\to\your\cmder\bin
set CMDER_USER_CONFIG=C:\full\path\to\your\cmder\config

and new Powershell as Admin sessions will use your user_profile.ps1 script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants