## 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
This commit is contained in:
Dax T Games
2018-08-31 17:02:56 -05:00
committed by Benjamin Staneck
parent e4fb0d694b
commit 49da3745bc
7 changed files with 120 additions and 58 deletions

31
vendor/cmder.sh vendored
View File

@ -1,6 +1,6 @@
# DO NOT EDIT THIS FILE IT WILL BE OVERWRITTEN ON UPDATE
#
# Add portable user customizations ${CMDER_ROOT}/config/user-profile.sh,
# Add portable user customizations ${CMDER_ROOT}/config/user_profile.sh,
# these customizations will follow Cmder if $CMDER_ROOT is copied
# to another machine.
#
@ -63,21 +63,32 @@ if [ -d "${CMDER_USER_CONFIG}/profile.d" ] ; then
runProfiled "${CMDER_USER_CONFIG}/profile.d"
fi
initialConfig="${CMDER_ROOT}/config/user-profile.sh"
if [ -f "${CMDER_ROOT}/config/user-profile.sh" ] ; then
. "${CMDER_ROOT}/config/user-profile.sh"
# Renaming to "config\user_profile.sh" to "user_profile.sh" for consistency.
if [ -f "$CMDER_ROOT/config/user-profile.sh" ] ; then
mv "$CMDER_ROOT/config/user-profile.sh" "$CMDER_ROOT/config/user_profile.sh"
fi
CmderUserProfilePath="${CMDER_ROOT}/config/user_profile.sh"
if [ -f "${CMDER_ROOT}/config/user_profile.sh" ] ; then
. "${CMDER_ROOT}/config/user_profile.sh"
fi
if [ "${CMDER_USER_CONFIG}" != "" ] ; then
initialConfig="${CMDER_USER_CONFIG}/user-profile.sh"
if [ -f "${CMDER_USER_CONFIG}/user-profile.sh" ] ; then
. "${CMDER_USER_CONFIG}/user-profile.sh"
# Renaming to "config\user_profile.sh" to "user_profile.sh" for consistency.
if [ -f "$CMDER_USER_CONFIG/user-profile.sh" ] ; then
mv "$CMDER_USER_CONFIG/user-profile.sh" "$CMDER_USER_CONFIG/user_profile.sh"
fi
CmderUserProfilePath="${CMDER_USER_CONFIG}/user_profile.sh"
if [ -f "${CMDER_USER_CONFIG}/user_profile.sh" ] ; then
. "${CMDER_USER_CONFIG}/user_profile.sh"
fi
fi
if [ ! -f "${initialConfig}" ] ; then
echo Creating user startup file: "${initialConfig}"
cat <<-eof >"${initialConfig}"
if [ ! -f "${CmderUserProfilePath}" ] ; then
echo Creating user startup file: "${CmderUserProfilePath}"
cat <<-eof >"${CmderUserProfilePath}"
# use this file to run your own startup commands for msys2 bash'
# To add a new vendor to the path, do something like:

58
vendor/cmder_exinit vendored
View File

@ -1,4 +1,4 @@
# Copy this file to your non integrated *nix-like environment,
# Copy this file to your non integrated *nix-like environment,
# Cygwin/MSys2/Git for Windows SDK, installs '/etc/profile.d/'
# folder to integrate the externally installed Unix like environment
# into Cmder so it has access to settings stored in Cmder/config
@ -15,7 +15,7 @@
# These customizations will follow Cmder if $CMDER_ROOT is copied
# to another machine.
#
# Add system specific users customizations to $HOME/.bashrc, these
# Add system specific users customizations to $HOME/.bashrc, these
# customizations will not follow Cmder to another machine.
# # Uncomment and edit the CMDER_ROOT line to use Cmder/config even when launched
@ -58,45 +58,55 @@ fi
if [ ! "$CMDER_ROOT" = "" ] ; then
# Remove any trailing '/'
CMDER_ROOT=$(echo $CMDER_ROOT | sed 's:/*$::')
echo "Using \"CMDER_ROOT\" at \"${CMDER_ROOT}\"."
export CMDER_ROOT
PATH=${CMDER_ROOT}/bin:$PATH:${CMDER_ROOT}
export PATH
# Drop *.sh or *.zsh files into "${CMDER_ROOT}\config\profile.d"
# to source them at startup.
if [ ! -d "${CMDER_ROOT}/config/profile.d" ] ; then
mkdir -p "${CMDER_ROOT}/config/profile.d"
fi
if [ -d "${CMDER_ROOT}/config/profile.d" ] ; then
runProfiled "${CMDER_ROOT}/config/profile.d"
fi
if [ -d "${CMDER_USER_CONFIG}/profile.d" ] ; then
runProfiled "${CMDER_USER_CONFIG}/profile.d"
fi
if [ -f "${CMDER_ROOT}/config/user-profile.sh" ] ; then
. "${CMDER_ROOT}/config/user-profile.sh"
# Renaming to "config\user_profile.sh" to "user_profile.sh" for consistency.
if [ -f "$CMDER_ROOT/config/user-profile.sh" ] ; then
mv "$CMDER_ROOT/config/user-profile.sh" "$CMDER_ROOT/config/user_profile.sh"
fi
if [ -f "${CMDER_USER_CONFIG}/user-profile.sh" ] ; then
. "${CMDER_USER_CONFIG}/user-profile.sh"
else
if [ "${CMDER_USER_CONFIG}" != "" ] ; then
initialProfile="${CMDER_USER_CONFIG}/user-profile.sh"
else
initialProfile="${CMDER_ROOT}/config/user-profile.sh"
fi
echo Creating user startup file: "${initialProfile}"
cat <<-eof >"${initialProfile}"
CmderUserProfilePath="${CMDER_ROOT}/config/user_profile.sh"
if [ -f "${CMDER_ROOT}/config/user_profile.sh" ] ; then
. "${CMDER_ROOT}/config/user_profile.sh"
fi
if [ "${CMDER_USER_CONFIG}" != "" ] ; then
# Renaming to "config\user_profile.sh" to "user_profile.sh" for consistency.
if [ -f "$CMDER_USER_CONFIG/user-profile.sh" ] ; then
mv "$CMDER_USER_CONFIG/user-profile.sh" "$CMDER_USER_CONFIG/user_profile.sh"
fi
CmderUserProfilePath="${CMDER_USER_CONFIG}/user_profile.sh"
if [ -f "${CMDER_USER_CONFIG}/user_profile.sh" ] ; then
. "${CMDER_USER_CONFIG}/user_profile.sh"
fi
fi
if [ ! -f "${CmderUserProfilePath}" ] ; then
echo Creating user startup file: "${CmderUserProfilePath}"
cat <<-eof >"${CmderUserProfilePath}"
# use this file to run your own startup commands for msys2 bash'
# To add a new vendor to the path, do something like:

14
vendor/init.bat vendored
View File

@ -4,7 +4,7 @@
:: Created as part of cmder project
:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
:: !!! Use "%CMDER_ROOT%\config\user-profile.cmd" to add your own startup commands
:: !!! Use "%CMDER_ROOT%\config\user_profile.cmd" to add your own startup commands
:: Use /v command line arg or set to > 0 for verbose output to aid in debugging.
set verbose-output=0
@ -294,17 +294,17 @@ if exist "%GIT_INSTALL_ROOT%\post-install.bat" (
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" (
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
call "%CMDER_ROOT%\config\user-profile.cmd"
call "%CMDER_ROOT%\config\user_profile.cmd"
)
if defined CMDER_USER_CONFIG (
set "initialConfig=%CMDER_USER_CONFIG%\user-profile.cmd"
if exist "%CMDER_USER_CONFIG%\user-profile.cmd" (
set "initialConfig=%CMDER_USER_CONFIG%\user_profile.cmd"
if exist "%CMDER_USER_CONFIG%\user_profile.cmd" (
REM Create this file and place your own command in there
call "%CMDER_USER_CONFIG%\user-profile.cmd"
call "%CMDER_USER_CONFIG%\user_profile.cmd"
)
)

18
vendor/profile.ps1 vendored
View File

@ -2,7 +2,7 @@
# Created as part of cmder project
# !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
# !!! Use "%CMDER_ROOT%\config\user-profile.ps1" to add your own startup commands
# !!! Use "%CMDER_ROOT%\config\user_profile.ps1" to add your own startup commands
# Compatibility with PS major versions <= 2
if(!$PSScriptRoot) {
@ -97,7 +97,7 @@ $env:Path = "$Env:CMDER_ROOT\bin;$env:Path;$Env:CMDER_ROOT"
#
# Prompt Section
# Users should modify their user-profile.ps1 as it will be safe from updates.
# Users should modify their user_profile.ps1 as it will be safe from updates.
#
# Pre assign the hooks so the first run of cmder gets a working prompt.
@ -149,16 +149,24 @@ if ($ENV:CMDER_USER_CONFIG -ne "" -and (test-path "$ENV:CMDER_USER_CONFIG\profil
popd
}
# Renaming to "config\user_profile.ps1" to "user_profile.ps1" for consistency.
if (test-path "$env:CMDER_ROOT\config\user-profile.ps1") {
rename-item "$env:CMDER_ROOT\config\user-profile.ps1" user_profile.ps1
}
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user-profile.ps1"
$CmderUserProfilePath = Join-Path $env:CMDER_ROOT "config\user_profile.ps1"
if (Test-Path $CmderUserProfilePath) {
# Create this file and place your own command in there.
Import-Module "$CmderUserProfilePath"
}
if ($ENV:CMDER_USER_CONFIG) {
$CmderUserProfilePath = Join-Path $ENV:CMDER_USER_CONFIG "user-profile.ps1"
# Renaming to "$env:CMDER_USER_CONFIG\user-profile.ps1" to "user_profile.ps1" for consistency.
if (test-path "$env:CMDER_USER_CONFIG\user-profile.ps1") {
rename-item "$env:CMDER_USER_CONFIG\user-profile.ps1" user_profile.ps1
}
$CmderUserProfilePath = Join-Path $ENV:CMDER_USER_CONFIG "user_profile.ps1"
if (Test-Path $CmderUserProfilePath) {
Import-Module "$CmderUserProfilePath"
}