mirror of
https://github.com/cmderdev/cmder.git
synced 2025-11-09 21:59:08 +08:00
Compare commits
24 Commits
copilot/fi
...
copilot/op
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b254bad5de | ||
|
|
49b7eee23a | ||
|
|
f90d276657 | ||
|
|
e99dc4d7e6 | ||
|
|
00636cf013 | ||
|
|
7f0cfac498 | ||
|
|
dc3b142b32 | ||
|
|
9c3bbe9b24 | ||
|
|
be44bac956 | ||
|
|
4fb6bed907 | ||
|
|
f4e68b0388 | ||
|
|
a824b721cb | ||
|
|
153f7310a1 | ||
|
|
3172771f15 | ||
|
|
ef46d6465d | ||
|
|
eabadf96dc | ||
|
|
7b248bc9a3 | ||
|
|
2ce0146d6e | ||
|
|
5dfa14ccce | ||
|
|
4d259ba84c | ||
|
|
bbd7507b4e | ||
|
|
b9246177c0 | ||
|
|
a8d897f633 | ||
|
|
304b8c7a05 |
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -48,7 +48,7 @@ jobs:
|
||||
cmd /c vendor\init.bat /v /d /t
|
||||
- name: Testing PowerShell
|
||||
run: |
|
||||
PowerShell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "Invoke-Expression '. ''vendor\profile.ps1'''"
|
||||
PowerShell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "$env:CMDER_DEBUG='1'; . 'vendor\profile.ps1'"
|
||||
- name: Testing Bash
|
||||
run: |
|
||||
bash vendor/cmder.sh
|
||||
|
||||
@@ -354,7 +354,7 @@ However, Cmder can in fact run in a variety of other terminal emulators, and eve
|
||||
|
||||
⚠ *Note:* Cmder includes built-in support for Windows Terminal directory tracking via OSC 9;9 sequences. This enables "Duplicate Tab" and "Split Pane" features to preserve the current working directory for both `cmd.exe` and PowerShell sessions.
|
||||
|
||||
⚠ *Note:* Cmder also includes built-in support for [Windows Terminal shell integration](https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration) via OSC 133 sequences (A, B, C) for PowerShell sessions. This enables features like command navigation (jump between commands), command selection, visual command separators, and improved command history management in Windows Terminal.
|
||||
⚠ *Note:* Cmder also includes built-in support for [Windows Terminal shell integration](https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration) via OSC 133 sequences (A, B, C, D) for PowerShell sessions. This enables features like command navigation (jump between commands), command selection, visual command separators, command exit code tracking, and improved command history management in Windows Terminal.
|
||||
|
||||
For instructions on how to integrate Cmder with your IDE, please read our [Wiki section](https://github.com/cmderdev/cmder/wiki#cmder-integration).
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
.EXAMPLE
|
||||
.\build.ps1 -SourcesPath '~/custom/vendors.json'
|
||||
|
||||
Build cmder with your own packages. See vendor/sources.json for the syntax you need to copy.
|
||||
Build Cmder with your own packages. See vendor/sources.json for the syntax you need to copy.
|
||||
.NOTES
|
||||
AUTHORS
|
||||
Samuel Vasko, Jack Bennett
|
||||
@@ -60,7 +60,7 @@ Param(
|
||||
[switch]$Compile
|
||||
)
|
||||
|
||||
# Get the scripts and cmder root dirs we are building in.
|
||||
# Get the scripts and Cmder root dirs we are building in.
|
||||
$cmder_root = Resolve-Path "$PSScriptRoot\.."
|
||||
|
||||
# Dot source util functions into this scope
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
.Synopsis
|
||||
Pack Cmder
|
||||
.DESCRIPTION
|
||||
Use this script to pack cmder into release archives
|
||||
Use this script to pack Cmder into release archives
|
||||
|
||||
You will need to make this script executable by setting your Powershell Execution Policy to Remote signed
|
||||
Then unblock the script for execution with UnblockFile .\pack.ps1
|
||||
.EXAMPLE
|
||||
.\pack.ps1
|
||||
|
||||
Creates default archives for cmder
|
||||
Creates default archives for Cmder
|
||||
.EXAMPLE
|
||||
.\pack.ps1 -verbose
|
||||
|
||||
Creates default archives for cmder with plenty of information
|
||||
Creates default archives for Cmder with plenty of information
|
||||
.NOTES
|
||||
AUTHORS
|
||||
Samuel Vasko, Jack Bennett, Martin Kemp
|
||||
|
||||
@@ -172,13 +172,13 @@ function Register-Cmder() {
|
||||
# Text for the context menu item.
|
||||
$MenuText = "Cmder Here"
|
||||
|
||||
, # Defaults to the current cmder directory when run from cmder.
|
||||
, # Defaults to the current Cmder directory when run from Cmder.
|
||||
$PathToExe = (Join-Path $env:CMDER_ROOT "cmder.exe")
|
||||
|
||||
, # Commands the context menu will execute.
|
||||
$Command = "%V"
|
||||
|
||||
, # Defaults to the icons folder in the cmder package.
|
||||
, # Defaults to the icons folder in the Cmder package.
|
||||
$icon = (Split-Path $PathToExe | Join-Path -ChildPath 'icons/cmder.ico')
|
||||
)
|
||||
Begin
|
||||
|
||||
116
vendor/cmder.sh
vendored
116
vendor/cmder.sh
vendored
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# DO NOT EDIT THIS FILE IT WILL BE OVERWRITTEN ON UPDATE
|
||||
#
|
||||
# Add portable user customizations ${CMDER_ROOT}/config/user_profile.sh,
|
||||
@@ -7,93 +8,130 @@
|
||||
# Add system specific users customizations to $HOME/.bashrc, these
|
||||
# customizations will not follow Cmder to another machine.
|
||||
|
||||
function runProfiled {
|
||||
unset profile_d_scripts
|
||||
pushd "${1}" >/dev/null
|
||||
# Source all .sh scripts in a given directory
|
||||
# Args: $1 - directory path containing .sh scripts to source
|
||||
run_profile_d() {
|
||||
local profile_d_scripts
|
||||
pushd "${1}" >/dev/null || return
|
||||
# shellcheck disable=SC2035
|
||||
profile_d_scripts=$(ls *.sh 2>/dev/null)
|
||||
|
||||
if [ ! "x${profile_d_scripts}" = "x" ] ; then
|
||||
for x in ${profile_d_scripts} ; do
|
||||
# echo Sourcing "${1}/${x}"...
|
||||
. "${1}/${x}"
|
||||
if [ -n "${profile_d_scripts}" ]; then
|
||||
for script in ${profile_d_scripts}; do
|
||||
# echo Sourcing "${1}/${script}"...
|
||||
# shellcheck disable=SC1090
|
||||
. "${1}/${script}"
|
||||
done
|
||||
fi
|
||||
popd >/dev/null
|
||||
popd >/dev/null || return
|
||||
}
|
||||
|
||||
# We do this for bash as admin sessions since $CMDER_ROOT is not being set
|
||||
if [ "$CMDER_ROOT" == "" ] ; then
|
||||
case "$ConEmuDir" in *\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." ; pwd );; esac
|
||||
# Detect and set CMDER_ROOT for bash admin sessions
|
||||
# Converts Windows paths to Unix paths if needed
|
||||
# ConEmuDir is set by ConEmu/Cmder environment
|
||||
if [ -z "$CMDER_ROOT" ]; then
|
||||
# Try to get CMDER_ROOT from ConEmuDir
|
||||
case "$ConEmuDir" in
|
||||
*\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." && pwd );;
|
||||
esac
|
||||
|
||||
# If still not set, derive from script location (vendor -> root)
|
||||
if [ -z "$CMDER_ROOT" ]; then
|
||||
CMDER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
|
||||
fi
|
||||
else
|
||||
case "$CMDER_ROOT" in *\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";; esac
|
||||
case "$CMDER_ROOT" in
|
||||
*\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Remove any trailing '/'
|
||||
CMDER_ROOT=$(echo $CMDER_ROOT | sed 's:/*$::')
|
||||
# Remove any trailing '/' from CMDER_ROOT
|
||||
CMDER_ROOT="${CMDER_ROOT%/}"
|
||||
|
||||
# Exit early if CMDER_ROOT is not set
|
||||
if [ -z "$CMDER_ROOT" ]; then
|
||||
echo "Warning: CMDER_ROOT is not set. Cmder integration skipped."
|
||||
# shellcheck disable=SC2317
|
||||
return 2>/dev/null || exit 0
|
||||
fi
|
||||
|
||||
export CMDER_ROOT
|
||||
|
||||
if [ -f "/c/Program Files/Git/cmd/git.exe" ] ; then
|
||||
# Detect Git installation location
|
||||
if [ -f "/c/Program Files/Git/cmd/git.exe" ]; then
|
||||
GIT_INSTALL_ROOT="/c/Program Files/Git"
|
||||
elif [ -f "/c/Program Files(x86)/Git/cmd/git.exe" ] ; then
|
||||
elif [ -f "/c/Program Files(x86)/Git/cmd/git.exe" ]; then
|
||||
GIT_INSTALL_ROOT="/c/Program Files(x86)/Git"
|
||||
elif [ -f "${CMDER_ROOT}/vendor/git-for-windows/cmd/git.exe" ] ; then
|
||||
GIT_INSTALL_ROOT=${CMDER_ROOT}/vendor/git-for-windows
|
||||
elif [ -f "${CMDER_ROOT}/vendor/git-for-windows/cmd/git.exe" ]; then
|
||||
GIT_INSTALL_ROOT="${CMDER_ROOT}/vendor/git-for-windows"
|
||||
fi
|
||||
|
||||
if [[ ! "$PATH" =~ "${GIT_INSTALL_ROOT}/bin:" ]] ; then
|
||||
# Add Git to PATH if not already present
|
||||
if [[ -n "${GIT_INSTALL_ROOT}" && ! "$PATH" =~ ${GIT_INSTALL_ROOT}/bin: ]]; then
|
||||
PATH="${GIT_INSTALL_ROOT}/bin:$PATH"
|
||||
fi
|
||||
|
||||
# Add Cmder directories to PATH
|
||||
PATH="${CMDER_ROOT}/bin:${CMDER_ROOT}/vendor/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
|
||||
# Create profile.d directory if it doesn't exist
|
||||
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"
|
||||
# Source all .sh scripts in profile.d directories
|
||||
if [ -d "${CMDER_ROOT}/config/profile.d" ]; then
|
||||
run_profile_d "${CMDER_ROOT}/config/profile.d"
|
||||
fi
|
||||
|
||||
if [ -d "${CMDER_USER_CONFIG}/profile.d" ] ; then
|
||||
runProfiled "${CMDER_USER_CONFIG}/profile.d"
|
||||
if [ -d "${CMDER_USER_CONFIG}/profile.d" ]; then
|
||||
run_profile_d "${CMDER_USER_CONFIG}/profile.d"
|
||||
fi
|
||||
|
||||
|
||||
# Renaming to "config\user_profile.sh" to "user_profile.sh" for consistency.
|
||||
if [ -f "$CMDER_ROOT/config/user-profile.sh" ] ; then
|
||||
# Rename legacy 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
|
||||
# Source user profile from CMDER_ROOT config
|
||||
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
|
||||
# Handle CMDER_USER_CONFIG if set
|
||||
if [ -n "${CMDER_USER_CONFIG}" ]; then
|
||||
# Rename legacy 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
|
||||
|
||||
export PATH="${CMDER_USER_CONFIG}/bin:$PATH"
|
||||
|
||||
CmderUserProfilePath="${CMDER_USER_CONFIG}/user_profile.sh"
|
||||
if [ -f "${CMDER_USER_CONFIG}/user_profile.sh" ] ; then
|
||||
# Source user profile from CMDER_USER_CONFIG
|
||||
if [ -f "${CMDER_USER_CONFIG}/user_profile.sh" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${CMDER_USER_CONFIG}/user_profile.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f "${CmderUserProfilePath}" ] ; then
|
||||
echo Creating user startup file: "${CmderUserProfilePath}"
|
||||
cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${CmderUserProfilePath}"
|
||||
# Determine the user profile path for creation if needed
|
||||
if [ -n "${CMDER_USER_CONFIG}" ]; then
|
||||
cmder_user_profile_path="${CMDER_USER_CONFIG}/user_profile.sh"
|
||||
else
|
||||
cmder_user_profile_path="${CMDER_ROOT}/config/user_profile.sh"
|
||||
fi
|
||||
|
||||
# Create user profile from default template if it doesn't exist
|
||||
if [ ! -f "${cmder_user_profile_path}" ] && [ -f "${CMDER_ROOT}/vendor/user_profile.sh.default" ]; then
|
||||
echo "Creating user startup file: ${cmder_user_profile_path}"
|
||||
cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${cmder_user_profile_path}"
|
||||
fi
|
||||
|
||||
# Source the users .bashrc file if it exists
|
||||
if [ -f "${HOME}/.bashrc" ] ; then
|
||||
if [ -f "${HOME}/.bashrc" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${HOME}/.bashrc"
|
||||
fi
|
||||
|
||||
123
vendor/cmder_exinit
vendored
123
vendor/cmder_exinit
vendored
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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
|
||||
@@ -22,92 +23,130 @@
|
||||
# # from outside Cmder.
|
||||
# CMDER_ROOT=${USERPROFILE}/cmder # This is not required if launched from Cmder.
|
||||
|
||||
function runProfiled {
|
||||
unset profile_d_scripts
|
||||
pushd "${1}" >/dev/null
|
||||
# Source all .sh or .zsh scripts in a given directory based on shell type
|
||||
# Args: $1 - directory path containing shell scripts to source
|
||||
run_profile_d() {
|
||||
local profile_d_scripts
|
||||
pushd "${1}" >/dev/null || return
|
||||
|
||||
if [ ! "x${ZSH_VERSION}" = "x" ]; then
|
||||
if [ -n "${ZSH_VERSION}" ]; then
|
||||
# shellcheck disable=SC2035
|
||||
profile_d_scripts=$(ls *.zsh 2>/dev/null)
|
||||
elif [ ! "x${BASH_VERSION}" = "x" ]; then
|
||||
elif [ -n "${BASH_VERSION}" ]; then
|
||||
# shellcheck disable=SC2035
|
||||
profile_d_scripts=$(ls *.sh 2>/dev/null)
|
||||
fi
|
||||
|
||||
if [ ! "x${profile_d_scripts}" = "x" ] ; then
|
||||
for x in ${profile_d_scripts} ; do
|
||||
echo Sourcing "${1}/${x}"...
|
||||
. "${1}/${x}"
|
||||
if [ -n "${profile_d_scripts}" ]; then
|
||||
for script in ${profile_d_scripts}; do
|
||||
echo "Sourcing ${1}/${script}..."
|
||||
# shellcheck disable=SC1090
|
||||
. "${1}/${script}"
|
||||
done
|
||||
fi
|
||||
popd >/dev/null
|
||||
popd >/dev/null || return
|
||||
}
|
||||
|
||||
# Check that we haven't already been sourced.
|
||||
# Check that we haven't already been sourced
|
||||
[[ -z ${CMDER_EXINIT} ]] && CMDER_EXINIT="1" || return
|
||||
|
||||
# We do this for bash as admin sessions since $CMDER_ROOT is not being set
|
||||
if [ "$CMDER_ROOT" = "" -a "$ConEmuDir" != "" ] ; then
|
||||
if [ -d "${ConEmuDir}../../vendor" ] ; then
|
||||
case "$ConEmuDir" in *\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." ; pwd );; esac
|
||||
# Detect and set CMDER_ROOT for bash admin sessions
|
||||
# Converts Windows paths to Unix paths if needed
|
||||
# ConEmuDir is set by ConEmu/Cmder environment
|
||||
if [ -z "$CMDER_ROOT" ] && [ -n "$ConEmuDir" ]; then
|
||||
if [ -d "${ConEmuDir}../../vendor" ]; then
|
||||
case "$ConEmuDir" in
|
||||
*\\*) CMDER_ROOT=$( cd "$(cygpath -u "$ConEmuDir")/../.." && pwd );;
|
||||
esac
|
||||
else
|
||||
echo "Running in ConEmu without Cmder, skipping Cmder integration."
|
||||
fi
|
||||
elif [ "$CMDER_ROOT" != "" ] ; then
|
||||
case "$CMDER_ROOT" in *\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";; esac
|
||||
elif [ -n "$CMDER_ROOT" ]; then
|
||||
case "$CMDER_ROOT" in
|
||||
*\\*) CMDER_ROOT="$(cygpath -u "$CMDER_ROOT")";;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ ! "$CMDER_ROOT" = "" ] ; then
|
||||
# Remove any trailing '/'
|
||||
CMDER_ROOT=$(echo $CMDER_ROOT | sed 's:/*$::')
|
||||
# If CMDER_ROOT is still not set, try to derive from script location
|
||||
# Note: This only works if cmder_exinit is in its original location (vendor/)
|
||||
if [ -z "$CMDER_ROOT" ] && [ -f "${BASH_SOURCE[0]}" ]; then
|
||||
# Check if we're in the vendor directory
|
||||
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
if [[ "$script_dir" == */vendor ]] || [[ "$script_dir" == */vendor/* ]]; then
|
||||
# Extract the Cmder root (parent of vendor)
|
||||
CMDER_ROOT="$( cd "$script_dir/.." && pwd )"
|
||||
# Verify this looks like a Cmder installation
|
||||
if [ ! -d "${CMDER_ROOT}/vendor" ]; then
|
||||
unset CMDER_ROOT
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Using \"CMDER_ROOT\" at \"${CMDER_ROOT}\"."
|
||||
if [ -n "$CMDER_ROOT" ]; then
|
||||
# Remove any trailing '/' from CMDER_ROOT
|
||||
CMDER_ROOT="${CMDER_ROOT%/}"
|
||||
|
||||
echo "Using CMDER_ROOT at \"${CMDER_ROOT}\"."
|
||||
|
||||
export CMDER_ROOT
|
||||
|
||||
PATH=${CMDER_ROOT}/bin:${CMDER_ROOT}/vendor/bin:$PATH:${CMDER_ROOT}
|
||||
# Add Cmder directories to PATH
|
||||
PATH="${CMDER_ROOT}/bin:${CMDER_ROOT}/vendor/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
|
||||
# Create profile.d directory if it doesn't exist
|
||||
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"
|
||||
# Source all shell scripts in profile.d directories
|
||||
if [ -d "${CMDER_ROOT}/config/profile.d" ]; then
|
||||
run_profile_d "${CMDER_ROOT}/config/profile.d"
|
||||
fi
|
||||
|
||||
if [ -d "${CMDER_USER_CONFIG}/profile.d" ] ; then
|
||||
runProfiled "${CMDER_USER_CONFIG}/profile.d"
|
||||
if [ -d "${CMDER_USER_CONFIG}/profile.d" ]; then
|
||||
run_profile_d "${CMDER_USER_CONFIG}/profile.d"
|
||||
fi
|
||||
|
||||
|
||||
# Renaming to "config\user_profile.sh" to "user_profile.sh" for consistency.
|
||||
if [ -f "$CMDER_ROOT/config/user-profile.sh" ] ; then
|
||||
# Rename legacy 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
|
||||
# Source user profile from CMDER_ROOT config
|
||||
if [ -f "${CMDER_ROOT}/config/user_profile.sh" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${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
|
||||
# Handle CMDER_USER_CONFIG if set
|
||||
if [ -n "${CMDER_USER_CONFIG}" ]; then
|
||||
# Rename legacy 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
|
||||
|
||||
export PATH=${CMDER_USER_CONFIG}/bin:$PATH
|
||||
export PATH="${CMDER_USER_CONFIG}/bin:$PATH"
|
||||
|
||||
CmderUserProfilePath="${CMDER_USER_CONFIG}/user_profile.sh"
|
||||
if [ -f "${CMDER_USER_CONFIG}/user_profile.sh" ] ; then
|
||||
# Source user profile from CMDER_USER_CONFIG
|
||||
if [ -f "${CMDER_USER_CONFIG}/user_profile.sh" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. "${CMDER_USER_CONFIG}/user_profile.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f "${CmderUserProfilePath}" ] ; then
|
||||
echo Creating user startup file: "${CmderUserProfilePath}"
|
||||
cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${CmderUserProfilePath}"
|
||||
# Determine the user profile path for creation if needed
|
||||
if [ -n "${CMDER_USER_CONFIG}" ]; then
|
||||
cmder_user_profile_path="${CMDER_USER_CONFIG}/user_profile.sh"
|
||||
else
|
||||
cmder_user_profile_path="${CMDER_ROOT}/config/user_profile.sh"
|
||||
fi
|
||||
|
||||
# Create user profile from default template if it doesn't exist
|
||||
if [ ! -f "${cmder_user_profile_path}" ] && [ -f "${CMDER_ROOT}/vendor/user_profile.sh.default" ]; then
|
||||
echo "Creating user startup file: ${cmder_user_profile_path}"
|
||||
cp "${CMDER_ROOT}/vendor/user_profile.sh.default" "${cmder_user_profile_path}"
|
||||
fi
|
||||
fi
|
||||
|
||||
49
vendor/git-prompt.sh
vendored
49
vendor/git-prompt.sh
vendored
@@ -5,9 +5,9 @@ function getGitStatusSetting() {
|
||||
# Get all git config entries for the current repository without pager
|
||||
gitConfig=$(git --no-pager config -l 2>/dev/null) || return 0 # treat failure as enabled
|
||||
|
||||
# Check if git status for Cmder is disabled
|
||||
if [[ $gitConfig =~ (^|$'\n')cmder\.status=false($|$'\n') ]] || \
|
||||
[[ $gitConfig =~ (^|$'\n')cmder\.shstatus=false($|$'\n') ]]
|
||||
# Check if git status display for Cmder is disabled via config
|
||||
# Matches: cmder.status=false or cmder.shstatus=false (Bash-specific)
|
||||
if [[ $gitConfig =~ (^|$'\n')cmder\.(sh)?status=false($|$'\n') ]]
|
||||
then
|
||||
return 1 # disabled
|
||||
fi
|
||||
@@ -47,9 +47,41 @@ then
|
||||
. ~/.config/git/git-prompt.sh
|
||||
fi
|
||||
else
|
||||
# Taken parts from https://github.com/git-for-windows/build-extra/blob/main/git-extra/git-prompt.sh
|
||||
|
||||
# Setup OSC 133 shell integration for Windows Terminal
|
||||
if [ -n "$WT_SESSION" ]; then
|
||||
__cmder_prompt_command() {
|
||||
local exit_code=$?
|
||||
# Emit OSC 133;D to mark the end of command execution with exit code
|
||||
printf '\e]133;D;%s\a' "$exit_code"
|
||||
return $exit_code
|
||||
}
|
||||
|
||||
__cmder_preexec() {
|
||||
# Emit OSC 133;C to mark the start of command execution
|
||||
printf '\e]133;C\a'
|
||||
}
|
||||
|
||||
# Append to PROMPT_COMMAND to emit sequences just before each prompt
|
||||
if [ -z "$PROMPT_COMMAND" ]; then
|
||||
PROMPT_COMMAND="__cmder_prompt_command"
|
||||
else
|
||||
PROMPT_COMMAND="__cmder_prompt_command;$PROMPT_COMMAND"
|
||||
fi
|
||||
|
||||
# Use DEBUG trap to emit OSC 133;C before command execution
|
||||
trap '__cmder_preexec' DEBUG
|
||||
fi
|
||||
|
||||
# Source: github.com/git-for-windows/build-extra/blob/main/git-extra/git-prompt.sh
|
||||
PS1='\[\033]0;${TITLEPREFIX:+$TITLEPREFIX:}${PWD//[^[:ascii:]]/?}\007\]' # set window title to TITLEPREFIX (if set) and current working directory
|
||||
# PS1="$PS1"'\n' # new line (disabled)
|
||||
|
||||
if [ -n "$WT_SESSION" ]; then
|
||||
# Emit OSC 133;A to mark the start of prompt
|
||||
PS1="$PS1"'\e]133;A\a'
|
||||
fi
|
||||
|
||||
PS1="$PS1"'\[\033[32m\]' # change to green and bold
|
||||
PS1="$PS1"'\u@\h ' # user@host<space>
|
||||
PS1="$PS1${MSYSTEM:+\[\033[35m\]$MSYSTEM }" # show MSYSTEM in purple (if set)
|
||||
@@ -70,7 +102,7 @@ else
|
||||
PS1="$PS1"'\[\033[36m\]' # change color to cyan
|
||||
PS1="$PS1"'`__git_ps1`' # bash function
|
||||
else
|
||||
PS1="$PS1"'\[\033[37;1m\]' # change color to white
|
||||
PS1="$PS1"'\[\033[37;1m\]' # change color to white
|
||||
PS1="$PS1"'`getSimpleGitBranch`'
|
||||
fi
|
||||
fi
|
||||
@@ -80,9 +112,14 @@ else
|
||||
PS1="$PS1"'\[\033[30;1m\]' # change color to grey in bold
|
||||
PS1="$PS1"'λ ' # prompt: Cmder uses λ
|
||||
PS1="$PS1"'\[\033[0m\]' # reset color
|
||||
|
||||
if [ -n "$WT_SESSION" ]; then
|
||||
# Emit OSC 133;B to mark the end of prompt
|
||||
PS1="$PS1"'\[\e]133;B\a\]'
|
||||
fi
|
||||
fi
|
||||
|
||||
MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc
|
||||
MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc
|
||||
|
||||
# Evaluate all user-specific Bash completion scripts (if any)
|
||||
if test -z "$WINELOADERNOEXEC"
|
||||
|
||||
3
vendor/init.bat
vendored
3
vendor/init.bat
vendored
@@ -222,6 +222,9 @@ goto :SKIP_CLINK
|
||||
|
||||
:: Revert back to plain cmd.exe prompt without clink
|
||||
prompt $E[1;32;49m$P$S$_$E[1;30;49mλ$S$E[0m
|
||||
|
||||
:: Add Windows Terminal shell integration support (OSC 133 sequences)
|
||||
if defined WT_SESSION (prompt $e]133;D$e\$e]133;A$e\$e]9;9;$P$e\%PROMPT%$e]133;B$e\)
|
||||
|
||||
chcp %cp%>nul
|
||||
|
||||
|
||||
91
vendor/profile.ps1
vendored
91
vendor/profile.ps1
vendored
@@ -7,15 +7,11 @@
|
||||
|
||||
$CMDER_INIT_START = Get-Date
|
||||
|
||||
# Compatibility with PS major versions <= 2
|
||||
# Determine the script root if not already set
|
||||
if (!$PSScriptRoot) {
|
||||
$PSScriptRoot = Split-Path $Script:MyInvocation.MyCommand.Path
|
||||
}
|
||||
|
||||
if ($ENV:CMDER_USER_CONFIG) {
|
||||
Write-Verbose "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '$ENV:CMDER_USER_CONFIG'!"
|
||||
}
|
||||
|
||||
# We do this for Powershell as Admin Sessions because CMDER_ROOT is not being set.
|
||||
if (!$ENV:CMDER_ROOT) {
|
||||
if ($ENV:ConEmuDir) {
|
||||
@@ -31,6 +27,12 @@ $ENV:CMDER_ROOT = ($ENV:CMDER_ROOT).TrimEnd("\")
|
||||
# Recent PowerShell versions include PowerShellGet out of the box
|
||||
$moduleInstallerAvailable = [bool](Get-Command -Name 'Install-Module' -ErrorAction SilentlyContinue)
|
||||
|
||||
# Enable Debug and Verbose output if CMDER_DEBUG environment variable is set to '1' or 'true'
|
||||
if ($env:CMDER_DEBUG -and ($env:CMDER_DEBUG -match '^(1|true)$')) {
|
||||
$DebugPreference = 'Continue'
|
||||
$VerbosePreference = 'Continue'
|
||||
}
|
||||
|
||||
# Add Cmder modules directory to the autoload path.
|
||||
$CmderModulePath = Join-path $PSScriptRoot "psmodules/"
|
||||
|
||||
@@ -43,28 +45,40 @@ if (-not $moduleInstallerAvailable -and -not $env:PSModulePath.Contains($CmderMo
|
||||
$env:PSModulePath = $env:PSModulePath.Insert(0, "$CmderModulePath;")
|
||||
}
|
||||
|
||||
if ($env:CMDER_USER_CONFIG) {
|
||||
Write-Verbose "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '$ENV:CMDER_USER_CONFIG'!"
|
||||
}
|
||||
|
||||
# Read vendored Git Version
|
||||
$gitVersionVendor = Get-GitVersion -GitPath "$ENV:CMDER_ROOT\vendor\git-for-windows\cmd"
|
||||
Write-Debug "GIT VENDOR: ${gitVersionVendor}"
|
||||
$gitVendorPath = Join-Path $ENV:CMDER_ROOT 'vendor\git-for-windows\cmd'
|
||||
$gitVersionVendor = Get-GitVersion -GitPath $gitVendorPath
|
||||
if (-not [string]::IsNullOrEmpty($gitVersionVendor)) {
|
||||
Write-Debug "GIT VENDOR: ${gitVersionVendor}"
|
||||
} else {
|
||||
Write-Debug "GIT VENDOR is not present at '$gitVendorPath'"
|
||||
}
|
||||
|
||||
# Get user installed Git version(s) if found, and compare them with vendored version.
|
||||
foreach ($git in (Get-Command -ErrorAction SilentlyContinue 'git')) {
|
||||
Write-Debug "GIT PATH: {$git.Path}"
|
||||
Write-Debug "GIT USER PATH: $($git.Path)"
|
||||
$gitDir = Split-Path -Path $git.Path
|
||||
$gitDir = Get-GitShimPath -GitPath $gitDir
|
||||
$gitVersionUser = Get-GitVersion -GitPath $gitDir
|
||||
Write-Debug "GIT USER: ${gitVersionUser}"
|
||||
Write-Debug "GIT USER VERSION: ${gitVersionUser}"
|
||||
|
||||
$useGitVersion = Compare-GitVersion -UserVersion $gitVersionUser -VendorVersion $gitVersionVendor
|
||||
Write-Debug "Using Git Version: ${useGitVersion}"
|
||||
|
||||
# Use user installed Git
|
||||
if ($null -eq $gitPathUser) {
|
||||
Write-Debug "Detected Git from mingw bin directory"
|
||||
Write-Debug "Git Dir: ${gitDir}"
|
||||
if ($gitDir -match '\\mingw32\\bin' -or $gitDir -match '\\mingw64\\bin') {
|
||||
$gitPathUser = ($gitDir.subString(0,$gitDir.Length - 12))
|
||||
$gitPathUser = $gitDir.subString(0, $gitDir.Length - 12)
|
||||
} else {
|
||||
$gitPathUser = ($gitDir.subString(0,$gitDir.Length - 4))
|
||||
$gitPathUser = $gitDir.subString(0, $gitDir.Length - 4)
|
||||
}
|
||||
Write-Debug "Git Path User: ${gitDir}"
|
||||
}
|
||||
|
||||
if ($useGitVersion -eq $gitVersionUser) {
|
||||
@@ -97,20 +111,19 @@ if (Get-Command -Name "vim" -ErrorAction SilentlyContinue) {
|
||||
if (Get-Module PSReadline -ErrorAction "SilentlyContinue") {
|
||||
# Display an extra prompt line between the prompt and the command input
|
||||
Set-PSReadlineOption -ExtraPromptLineCount 1
|
||||
|
||||
# Add OSC 133;C support for Windows Terminal shell integration
|
||||
# This marks the start of command output (emitted when Enter is pressed)
|
||||
|
||||
# Invoked when Enter is pressed to submit a command
|
||||
if ($env:WT_SESSION) {
|
||||
Set-PSReadLineKeyHandler -Key Enter -ScriptBlock {
|
||||
# Get the current command line
|
||||
$line = $null
|
||||
$cursor = $null
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
|
||||
|
||||
|
||||
# Accept the line first
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
|
||||
|
||||
# Emit OSC 133;C sequence to mark start of command output
|
||||
|
||||
# Emit OSC 133;C to mark start of command output
|
||||
# This is written directly to the console after the command is accepted
|
||||
[Console]::Write("$([char]0x1B)]133;C$([char]7)")
|
||||
}
|
||||
@@ -220,23 +233,28 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
|
||||
[ScriptBlock]$Prompt = {
|
||||
$lastSUCCESS = $?
|
||||
$realLastExitCode = $LastExitCode
|
||||
|
||||
# Emit OSC 9;9 sequence for Windows Terminal directory tracking
|
||||
# This enables "Duplicate Tab" and "Split Pane" to preserve the working directory
|
||||
# Only active in Windows Terminal ($env:WT_SESSION) or ConEmu ($env:ConEmuPID)
|
||||
$loc = $executionContext.SessionState.Path.CurrentLocation
|
||||
if (($env:WT_SESSION -or $env:ConEmuPID) -and $loc.Provider.Name -eq "FileSystem") {
|
||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]9;9;`"$($loc.ProviderPath)`"$([char]0x1B)\"
|
||||
|
||||
# Terminal-specific escape sequences for Windows Terminal and ConEmu
|
||||
if ($env:WT_SESSION -or $env:ConEmuPID) {
|
||||
# Emit OSC 133;D to mark the end of command execution with exit code
|
||||
if ($env:WT_SESSION) {
|
||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;D;$realLastExitCode$([char]7)"
|
||||
}
|
||||
|
||||
# Emit OSC 9;9 to enable directory tracking
|
||||
# Enables "Duplicate Tab" and "Split Pane" to preserve the working directory
|
||||
$loc = $executionContext.SessionState.Path.CurrentLocation
|
||||
if ($loc.Provider.Name -eq "FileSystem") {
|
||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]9;9;`"$($loc.ProviderPath)`"$([char]0x1B)\"
|
||||
}
|
||||
|
||||
# Emit OSC 133;A to mark the start of the prompt
|
||||
# Enables features like command navigation, selection, and visual separators
|
||||
if ($env:WT_SESSION) {
|
||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;A$([char]7)"
|
||||
}
|
||||
}
|
||||
|
||||
# Emit OSC 133;A sequence for Windows Terminal shell integration
|
||||
# This marks the start of the prompt
|
||||
# Enables features like command navigation, selection, and visual separators
|
||||
# Only active in Windows Terminal ($env:WT_SESSION)
|
||||
if ($env:WT_SESSION) {
|
||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;A$([char]7)"
|
||||
}
|
||||
|
||||
|
||||
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf
|
||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x200B)`r$([char]0x1B)[K"
|
||||
if ($lastSUCCESS -or ($LastExitCode -ne 0)) {
|
||||
@@ -245,13 +263,12 @@ if ( $(Get-Command prompt).Definition -match 'PS \$\(\$executionContext.SessionS
|
||||
PrePrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||
CmderPrompt
|
||||
PostPrompt | Microsoft.PowerShell.Utility\Write-Host -NoNewline
|
||||
|
||||
# Emit OSC 133;B sequence for Windows Terminal shell integration
|
||||
# This marks the start of command input (after prompt, before user types)
|
||||
|
||||
# Emit OSC 133;B to mark the start of command input (after prompt, before user types)
|
||||
if ($env:WT_SESSION) {
|
||||
Microsoft.PowerShell.Utility\Write-Host -NoNewline "$([char]0x1B)]133;B$([char]7)"
|
||||
}
|
||||
|
||||
|
||||
$global:LastExitCode = $realLastExitCode
|
||||
return " "
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user