Skip to content

Commit

Permalink
New cmder.exe args and shared install capability (cmderdev#1696)
Browse files Browse the repository at this point in the history
@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
  • Loading branch information
daxgames authored and MartiUK committed Mar 13, 2018
1 parent ff2e098 commit 997e799
Show file tree
Hide file tree
Showing 10 changed files with 944 additions and 342 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Auto detect text files and perform LF normalization
* text=auto
*.cmd text eol=crlf
*.bat text eol=crlf
*.ps1 text eol=crlf
*.md text eol=lf
*.sh text eol=lf
57 changes: 56 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
# Change Log

## [1.3.6-pre1](https://github.com/cmderdev/cmder) (2018-03-01)

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

* 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](./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]
1. %cmder_root%\config\user-profile.[cmd|ps1|sh]
1. %userprofile%\cmder_config\config\profile.d\*.[cmd|ps1|sh]
1. %userprofile%\cmder_config\config\user-profile.[cmd|ps1|sh]
## [1.3.5](https://github.com/cmderdev/cmder/releases/tag/v1.3.5) (2018-02-11)
This is the first Cmder release that comes with Git for Windows in the 64bit version. If you are still using a 32bit version, you have to fix this yourself.
Expand Down Expand Up @@ -746,4 +801,4 @@ We now use a forked version of clink since it's original author is missing and w
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
107 changes: 81 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,42 @@ Cmder is a **software package** created out of pure frustration over absence of
The main advantage of Cmder is portability. It is designed to be totally self-contained with no external dependencies, which makes it great for **USB Sticks** or **cloud storage**. So you can carry your console, aliases and binaries (like wget, curl and git) with you anywhere.

## Installation
### Single User Portable Config

1. Download the [latest release](https://github.com/cmderdev/cmder/releases/)
2. Extract the archive
3. (optional) Place your own executable files into the `bin` folder to be injected into your PATH. (nb: This path should not be `C:\Program Files` or anywhere else that would require Administrator access for modifying configuration files)
2. Extract the archive. *Note: This path should not be `C:\Program Files` or anywhere else that would require Administrator access for modifying configuration files*
3. (optional) Place your own executable files into the `%cmder_root%\bin` folder to be injected into your PATH.
4. Run Cmder.exe

## Integration
### Shared Cmder install with Non-Portable Individual User Config
1. Download the [latest release](https://github.com/cmderdev/cmder/releases/)
2. Extract the archive to a shared location.
3. (optional) Place your own executable files into the `%cmder_root%\bin` folder to be injected into your PATH.
4. (optional) Create `%userprofile%\cmder_config\bin` folder to be injected into individual users PATH. Default is to auto create this on first run.
5. (optional) Place your own executable files into the `%userprofile%\cmder_config\bin` folder to be injected into your PATH.
6. Run Cmder.exe with "/C" command line argument. Example: `cmder.exe /C %userprofile%\cmder_config`
* This will create the following directory structure if it is missing.

```
c:\users\[username]\cmder_config
├───bin
└───config
└───profile.d
```
* Both the shared install and the individual user config locations can contain a full set of init and profile.d scripts enabling shared config with user overrides. See below.
## Cmder.exe Command Line Arguments
| Argument | Description |
| ------------------- | ----------------------------------------------------------------------- |
| /C [user_root_path] | Individual user Cmder root folder. Example: %userprofile%\cmder_config |
| /SINGLE | Start Cmder is single mode. |
| /START [start_path] | Folder path to start in. |
| /TASK [task_name] | Task to start after launch. |
## Context Menu Integration
So you've experimented with Cmder a little and want to give it a shot in a more permanent home;
Expand Down Expand Up @@ -57,16 +86,16 @@ In a file explorer window right click in or on a directory to see "Cmder Here" i
### Access to multiple shells in one window using tabs
You can open multiple tabs each containing one of the following shells:
|Task|Shell|Description|
|----|-----|-----------|
|Cmder|cmd.exe|Windows 'cmd.exe' shell enhanced with Git, Git aware prompt, Clink(GNU Readline), and Aliases.|
|Cmder as Admin|cmd.exe|Administrative Windows 'cmd.exe' Cmder shell.|
|PowerShell|powershell.exe|Windows PowerShell enhanced with Git and Git aware prompt .|
|PowerShell as Admin|powershell.exe|Administrative Windows 'powershell.exe' Cmder shell.|
|Bash|bash.exe|Unix/Linux like bash shell running on Windows.|
|Bash as Admin|bash.exe|Administrative Unix/Linux like bash shell running on Windows.|
|Mintty|bash.exe|Unix/Linux like bash shell running on Windows. See below for Mintty configuration differences|
|Mintty as Admin|bash.exe|Administrative Unix/Linux like bash shell running on Windows. See below for Mintty configuration differences|
| Task | Shell | Description |
| ---- | ----- | ----------- |
| Cmder | cmd.exe | Windows 'cmd.exe' shell enhanced with Git, Git aware prompt, Clink(GNU Readline), and Aliases. |
| Cmder as Admin | cmd.exe | Administrative Windows 'cmd.exe' Cmder shell. |
| PowerShell | powershell.exe | Windows PowerShell enhanced with Git and Git aware prompt . |
| PowerShell as Admin | powershell.exe | Administrative Windows 'powershell.exe' Cmder shell. |
| Bash | bash.exe | Unix/Linux like bash shell running on Windows. |
| Bash as Admin | bash.exe | Administrative Unix/Linux like bash shell running on Windows. |
| Mintty | bash.exe | Unix/Linux like bash shell running on Windows. See below for Mintty configuration differences |
| Mintty as Admin | bash.exe | Administrative Unix/Linux like bash shell running on Windows. See below for Mintty configuration differences |
Cmder, PowerShell, and Bash tabs all run on top of the Windows Console API and work as you might expect in Cmder with access to use ConEmu's color schemes, key bindings and other settings defined in the ConEmu Settings dialog.
Expand All @@ -85,25 +114,51 @@ cd mintty-colors-solarized/
echo source \$CMDER_ROOT/vendor/mintty-colors-solarized/mintty-solarized-dark.sh>>$CMDER_ROOT/config/user-profile.sh
```
### Cmder Portable Shell User Config
User specific configuration is possible using the cmder specific shell config files. Edit the below files to add your own configuration:
### Changing Cmder Default 'cmd.exe' Shell Startup Behaviour Using Task Arguments
1. Press <kbd>Win</kbd> + <kbd>Alt</kbd> + <kbd>T</kbd>
1. Click either:
* `1. {cmd::Cmder as Admin}`
* `2. {cmd::Cmder}`
1. Add command line argumentswhere specified below:
*Note: Pay attention to the quotes!*
```
cmd /s /k ""%ConEmuDir%\..\init.bat" [ADD ARGS HERE]"
```
##### Command Line Arguments for `init.bat`
| 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 |
### Cmder Shell User Config
Single user portable configuration is possible using the cmder specific shell config files. Edit the below files to add your own configuration:
|Shell|Cmder Portable User Config|
| ------------- |:-------------:|
|Cmder|%CMDER_ROOT%\config\user-profile.cmd|
|PowerShell|$ENV:CMDER_ROOT\config\user-profile.ps1|
|Bash/Mintty|$CMDER_ROOT/config/user-profile.sh|
| Shell | Cmder Portable User Config |
| ------------- | ----------------------------------------- |
| Cmder | %CMDER_ROOT%\\config\\user-profile.cmd |
| PowerShell | $ENV:CMDER_ROOT\\config\\user-profile.ps1 |
| Bash/Mintty | $CMDER_ROOT/config/user-profile.sh |
Note: Bash and Mintty sessions will also source the '$HOME/.bashrc' file if it exists after it sources '$CMDER_ROOT/config/user-profile.sh'.
### Linux like 'profile.d' support for all supported shell types.
You can write *.cmd|*.bat, *.ps1, and *.sh scripts and just drop them in the %CMDER_ROOT%\config\profile.d folder to add startup config to Cmder.
|Shell|Cmder 'Profile.d' Scripts|
| ------------- |:-------------:|
|Cmder|%CMDER_ROOT%\config\profile.d\\*.bat and *.cmd|
|PowerShell|$ENV:CMDER_ROOT\config\profile.d\\*.ps1|
|Bash/Mintty|$CMDER_ROOT/config/profile.d/*.sh|
| Shell | Cmder 'Profile.d' Scripts |
| ------------- | --------------------------------------------------|
| Cmder | %CMDER_ROOT%\\config\\profile.d\\\*.bat and *.cmd |
| PowerShell | $ENV:CMDER_ROOT\\config\\profile.d\\\*.ps1 |
| Bash/Mintty | $CMDER_ROOT/config/profile.d/*.sh |
### Aliases
Expand Down
Loading

0 comments on commit 997e799

Please sign in to comment.