Per our email discussion, I have updated the HG prompt code to use the '-ib' option to 'hg id' so the branch name is always available, regardless of the state of the working copy.
In `string.gsub()`, the `%` character has special meaning and must be escaped to be treated verbatim, otherwise the "invalid use of '%' in replacement string" warning will show up.
This adds a verbatim() function for that purpose. It fixes this warning for situations where `'%` characters are in the current path (cwd), version control branch names, or in the previous `PROMPT` set by the user.
The below enables Cmder Fast Init mode for `cmd.exe` sessions. This is more like the Cmder 1.3.5 init process. See issue #1821
Cmder Fast Init mode bypasses or disables the following Cmder 1.3.6+ features:
* Git root and version detection. Defaults to `%cmder_root%\vendor\git-for-windows` if it exists.
* Path enhance validation before path modify so `%Path%` enhancements are forced.
* Recursive path add for `"%CMDER_ROOT%\bin"`
* Recursive path add for `"%CMDER_USER_BIN%\bin"` if `/c [user_config_folder` is specified.
* `/d` switch to enable debug output.
* `/v` switch to enable debug output.
Add `/f` to Cmder task as shown below t enable fast init:
_Note 1: This setting is invalid in Cmder `Powershell` and `Bash` sessions~_
_Note 2: Add `/t` also to see init timer output_
![image](https://user-images.githubusercontent.com/7318053/47957637-052e3880-df90-11e8-93ef-91e1ab696d82.png)
Cuts ~2.4 seconds off of init time.
![image](https://user-images.githubusercontent.com/7318053/47957795-45db8100-df93-11e8-8ae0-551d12c4e2dc.png)
If the git found is a shim, we need to follow the path to the actual git
directory to set the GIT_INSTALL_ROOT variable.
This happens when installing git via scoop for example.
## Rename user-profile.* user_profile.* to resolve#1806, #1675
* This is a backward compatible fix and will automatically and silently rename users '%cmder_root%/config/user-profile.\*' to '%cmder_root%/config/user_profile.\*' and '[user_specified_config_root]/user-profile.\*' to '[user_specified_config_root]/user_profile.\*' if the sources exist.
* Cmder.exe does this for cmd.exe sessions.
* The init scripts for bash and Powershell handles it for these shells
Fixes Powershell 5.1 error when Windows Software Restriction Policy is enabled:
bin\vendor\profile.ps1 : Cannot dot-source this command because it was defined in a different language mode. To invoke this command without importing its contents, omit the '.' operator.
At line:1 char:1
+ . 'bin\vendor\conemu-maximus5\..\profi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [profile.ps1], NotSupportedException
+ FullyQualifiedErrorId : DotSourceNotSupported,profile.ps1
@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.
https://github.com/cmderdev/cmder/issues/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
* Replaced the git version comparison mechanism with actual version comparing
* Add notes regarding the git comparison method
Added a simple mechanism to call and compare the user installed git version against the vendored git version, rather than checking if the `git.exe` executable is located in a `/bin` directory.
This fixes false warnings by actually testing if the user installed git is older, or more recent.
Added a small note regarding how the `init.bat` works, and where to put custom `git.exe` binaries as well as where to find the Minified Cmder.
Aliases such as `ls` may have been overridden in the user's profile script and the resulting behavior may be different from `Get-ChildItem`. For example binding `ls` to GNU `ls.exe` generates an error if there are no matching files.
* Fix Cmder not changing to CMDER_START
Fix to allow Cmder to change to different startup directory if already on the same drive as CMDER_START
possibly relevant: HOME != USERPROFILE
* make "Cmder Here" work in more cases
integrated suggestion from comments (test for trailing backslash to prevent doubling of trailing backslash)
integrated suggestions from #1456: switching ```cd /d``` over to ```pushd``` to get support for UNC-paths
* replaced 'cd /d' with 'pushd'
replaced two more instances of 'cd /d' with 'pushd' to support network paths.
Also added double quotes to the use of '%USERPROFILE%' to prevent issues with spaces.
I also noticed that 'pushd', in contrast to 'cd /d' does not require the trailing backslash for drive roots (on Win7). Therefore I removed the trailing backslash check.
* Don't assume / is needed at end
* Update init.bat
(and some comments on the user-profile.cmd file)
Inspired by the comments from https://github.com/cmderdev/cmder/issues/193 and my personal need to use pageant instead of OpenSSH authentication agents (which is more Window user-friendly), I have used this approach which works as expected.
Keeping the spirit of the current scripts, I left it disabled, and with some comments explaining what they all do.
If the Install-Module command is available, do not include the bundled
module path containing a deprecated version of PSGet. Recent powershell
versions include PowerShellGet as standard module installer.
Resolve#1318.
Currently the "history" command in Cmder prints commands without any index associated with any command, so you can copy/paste a command or use "!!" to execute a command from the history but, unlike BASH, you can't do "!<command_index>".
"cat" has a switch, "-n", which prints line numbers of the file being printed. This, in conjunction with "history_io=3" in Clink settings (to read/write history when editing a command") works just like BASH, i.e., you can use the index printed next to a command in the history to execute that command as "!<command_index>".
Currently the "history" command in Cmder prints commands without any index associated with any command, so you can copy/paste a command or use "!!" to execute a command from the history but, unlike BASH, you can't do "!<command_index>".
"cat" has a switch, "-n", which prints line numbers of the file being printed. This, in conjunction with "history_io=3" in Clink settings (to read/write history when editing a command") works just like BASH, i.e., you can use the index printed next to a command in the history to execute that command as "!<command_index>".
This defines the default prompt variables ($PrePrompt, $PostPrompt,
$CmderPrompt, and $Prompt) before running the custom scripts (user-profile.ps1
and profile.d/*.ps1), and then saves those prompt values after running the
custom scripts. This gives the custom scripts and opportunity to override the
prompt code blocks.
This now opens the possibility for profile.d/*.ps1 scripts to affect the
prompt, and also allows both user-profile.ps1 and profile.d/*.ps1 scripts to
overwrite the $Prompt script block and overwrite the prompt behavior entirely.