Posh-Git before this release does not export `Write-VcsStatus` thus
powershell's autoloading cannot find the reqired module for the function.
note that `get-module -listAvailable` can return an array of multiple
versions.
E.g., if ${CMDER_ROOT} is /c/Users/Foo Bar/cmder,
the following errors will occur:
bash: pushd: /c/Users/Foo: No such file or directory
bash: [: /c/Users/Foo: binary operator expected
bash: /c/Users/Foo: No such file or directory
clink.get_cwd() is returning a string which is differently encoded than what
clink.prompt.value expects. This results in garbled path names if the path
condains non-ASCII chars. The (arguable hacky) solution is to parse the old
prompt for the current directory (which breaks if the user sets a PROMPT env var
which is incompatible to the regex used here...).
Also parse out a environment name set by systems like virtualenv or conda: this
could be done more specifically by targeting each such system and using the
usually set environment variable but this would mean that we would have to do
that for each and every such system out there and that is probably not a sane
idea...
This keeps the PROMPT variable as is and changes the prompt to the cmder style
in the clink code.
This has two advantages:
* opening a cmd in a cmder session will now show the old prompt code instead of
a ugly raw prompt without the replacements. This led to ugly output when a
batch file echoed their content (e.g `conda build recipe/`).
* when a command rewrites the prompt (e.g. an activate in a virtualenv), these
command sometimes simply overwrites the PROMPT so that the cmder enhancements
were not anymore in place. Now we simply don't care and overwrite it with our
stuff in the clink part. This might mean that a user has to install a lua
script so that e.g. conda environments are visible on the prompt.
Add a pre and post function hook around the Cmder prompt.
Specify the cmder prompt as a function that could be replaced by a user.
Write a friendly message when the user profile template is created.
Create the user profile with cmder prompt hooks ready to use.
It was concerning to run any function with a specific name every prompt
with no guarantee it remains what it was initally created as.
Core functions have been explicitly called from their
namespace like Microsoft.PowerShell.Utility\Write-Host to try and prevent
clobbering.
User supplied functions are passed in as script blocks, created as the
session runs the profile script. By creating them as constants these
function names cannot be declared again for the duration of the process.
Since the prompt function already exists by this time, set the readOnly
flag so to re-declare the prompt requires the use of -force.
It is hoped these changes limit what could be the risk of any script
redefining functions that are called automatically without user intent or
input.