2018-09-01 06:02:56 +08:00
|
|
|
# Copy this file to your non integrated *nix-like environment,
|
2016-02-28 02:00:40 +08:00
|
|
|
# Cygwin/MSys2/Git for Windows SDK, installs '/etc/profile.d/'
|
2016-02-27 21:40:47 +08:00
|
|
|
# folder to integrate the externally installed Unix like environment
|
|
|
|
# into Cmder so it has access to settings stored in Cmder/config
|
|
|
|
# folder when launched.
|
2015-11-26 23:32:10 +08:00
|
|
|
#
|
|
|
|
# The destination file extension depends on the shell you use. For example:
|
|
|
|
#
|
|
|
|
# bash - Copy to /etc/profile.d/cmder_exinit.sh
|
|
|
|
# zsh - Copy to /etc/profile.d/cmder_exinit.zsh
|
2016-02-27 21:40:47 +08:00
|
|
|
# Add portable user customizations ${CMDER_ROOT}/config/user-profile.sh or
|
|
|
|
# add whole config scripts to ${CMDER_ROOT}/config/profile.d both will be sourced
|
2022-01-16 00:00:58 +08:00
|
|
|
# from this file and be applied to the environment at startup.
|
2016-02-27 21:40:47 +08:00
|
|
|
#
|
|
|
|
# These customizations will follow Cmder if $CMDER_ROOT is copied
|
2015-11-26 23:32:10 +08:00
|
|
|
# to another machine.
|
|
|
|
#
|
2018-09-01 06:02:56 +08:00
|
|
|
# Add system specific users customizations to $HOME/.bashrc, these
|
2015-11-26 23:32:10 +08:00
|
|
|
# customizations will not follow Cmder to another machine.
|
|
|
|
|
2016-02-28 02:00:40 +08:00
|
|
|
# # Uncomment and edit the CMDER_ROOT line to use Cmder/config even when launched
|
|
|
|
# # from outside Cmder.
|
|
|
|
# CMDER_ROOT=${USERPROFILE}/cmder # This is not required if launched from Cmder.
|
|
|
|
|
2018-03-13 23:38:27 +08:00
|
|
|
function runProfiled {
|
|
|
|
unset profile_d_scripts
|
|
|
|
pushd "${1}" >/dev/null
|
|
|
|
|
2023-09-23 05:15:23 +08:00
|
|
|
if [ -n "${ZSH_VERSION}" ]; then
|
2018-03-13 23:38:27 +08:00
|
|
|
profile_d_scripts=$(ls *.zsh 2>/dev/null)
|
2023-09-23 05:15:23 +08:00
|
|
|
elif [ -n "${BASH_VERSION}" ]; then
|
2018-03-13 23:38:27 +08:00
|
|
|
profile_d_scripts=$(ls *.sh 2>/dev/null)
|
|
|
|
fi
|
|
|
|
|
2023-09-23 05:15:23 +08:00
|
|
|
if [ -n "${profile_d_scripts}" ] ; then
|
2018-03-13 23:38:27 +08:00
|
|
|
for x in ${profile_d_scripts} ; do
|
|
|
|
. "${1}/${x}"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
2015-12-17 01:37:40 +08:00
|
|
|
# Check that we haven't already been sourced.
|
|
|
|
[[ -z ${CMDER_EXINIT} ]] && CMDER_EXINIT="1" || return
|
|
|
|
|
2023-11-12 09:29:28 +08:00
|
|
|
if [ -z "$CMDER_ROOT" ] && [ -n "$cmder_root" ] ; then
|
|
|
|
export CMDER_ROOT=$(cygpath -u $cmder_root)
|
|
|
|
fi
|
|
|
|
|
2015-11-26 23:32:10 +08:00
|
|
|
# We do this for bash as admin sessions since $CMDER_ROOT is not being set
|
|
|
|
if [ "$CMDER_ROOT" = "" -a "$ConEmuDir" != "" ] ; then
|
2023-06-06 01:22:28 +08:00
|
|
|
if [ -d "${ConEmuDir}/../../vendor" ] ; then
|
2016-02-28 02:00:40 +08:00
|
|
|
case "$ConEmuDir" in *\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." ; pwd );; esac
|
2015-12-17 01:37:40 +08:00
|
|
|
fi
|
2015-11-26 23:32:10 +08:00
|
|
|
elif [ "$CMDER_ROOT" != "" ] ; then
|
|
|
|
case "$CMDER_ROOT" in *\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";; esac
|
2015-12-17 01:37:40 +08:00
|
|
|
fi
|
|
|
|
|
2023-09-23 05:15:23 +08:00
|
|
|
if [ -n "$CMDER_ROOT" ] ; then
|
2016-02-28 02:00:40 +08:00
|
|
|
# Remove any trailing '/'
|
|
|
|
CMDER_ROOT=$(echo $CMDER_ROOT | sed 's:/*$::')
|
2018-09-01 06:02:56 +08:00
|
|
|
|
2016-02-28 02:00:40 +08:00
|
|
|
export CMDER_ROOT
|
2018-09-01 06:02:56 +08:00
|
|
|
|
2018-11-02 21:00:41 +08:00
|
|
|
PATH=${CMDER_ROOT}/bin:${CMDER_ROOT}/vendor/bin:$PATH:${CMDER_ROOT}
|
2018-09-01 06:02:56 +08:00
|
|
|
|
2016-02-28 02:00:40 +08:00
|
|
|
export PATH
|
2018-09-01 06:02:56 +08:00
|
|
|
|
2016-02-28 02:00:40 +08:00
|
|
|
# Drop *.sh or *.zsh files into "${CMDER_ROOT}\config\profile.d"
|
|
|
|
# to source them at startup.
|
|
|
|
if [ ! -d "${CMDER_ROOT}/config/profile.d" ] ; then
|
2016-08-21 07:01:46 +08:00
|
|
|
mkdir -p "${CMDER_ROOT}/config/profile.d"
|
2016-02-27 22:43:39 +08:00
|
|
|
fi
|
2018-09-01 06:02:56 +08:00
|
|
|
|
2016-02-28 02:00:40 +08:00
|
|
|
if [ -d "${CMDER_ROOT}/config/profile.d" ] ; then
|
2018-03-13 23:38:27 +08:00
|
|
|
runProfiled "${CMDER_ROOT}/config/profile.d"
|
2016-02-27 22:43:39 +08:00
|
|
|
fi
|
2018-09-01 06:02:56 +08:00
|
|
|
|
2018-03-13 23:38:27 +08:00
|
|
|
if [ -d "${CMDER_USER_CONFIG}/profile.d" ] ; then
|
|
|
|
runProfiled "${CMDER_USER_CONFIG}/profile.d"
|
|
|
|
fi
|
|
|
|
|
2018-09-01 06:02:56 +08:00
|
|
|
|
|
|
|
# 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"
|
2018-03-13 23:38:27 +08:00
|
|
|
fi
|
2018-09-01 06:02:56 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-11-02 21:00:41 +08:00
|
|
|
export PATH=${CMDER_USER_CONFIG}/bin:$PATH
|
|
|
|
|
2018-09-01 06:02:56 +08:00
|
|
|
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}"
|
2018-12-14 04:13:17 +08:00
|
|
|
cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${CmderUserProfilePath}"
|
2016-02-28 02:00:40 +08:00
|
|
|
fi
|
2015-11-26 23:32:10 +08:00
|
|
|
fi
|