Compare commits

..

6 Commits

Author SHA1 Message Date
05552dc51c added a comment 2025-07-16 04:18:03 +03:30
c6bfd6f276 Minor refactors to Git status and branch functions in git-prompt.sh
- `getGitStatusSetting`: use local variables, improve regex pattern, use return status codes instead of echo strings
- `getSimpleGitBranch`: better error handling, use local variables
- Simplified conditional checks
2025-07-16 04:16:47 +03:30
1d51c4f402 make bash prompt more consistent;
* display λ in grey and bold
* fix a bug where an uneeded colon would be prepended to the tab title (when MSYSTEM is unset)
2025-07-15 21:02:12 +03:30
aff4ad259f fix color values and names mismatch in comments 2025-07-15 20:25:59 +03:30
cb76868411 Import from upstream git-prompt.sh: user-specific bash completion scripts
Source: 061dbfe92b
2025-07-15 19:29:16 +03:30
abcb1a1aa1 display MSYSTEM if set; fix indentation; add comment 2025-07-15 19:26:49 +03:30
3 changed files with 57 additions and 35 deletions

View File

@ -48,15 +48,15 @@ prompt_overrideSvnStatusOptIn = false
-- Colors: https://github.com/cmderdev/cmder/wiki/Customization#list-of-colors
-- Effects: https://github.com/cmderdev/cmder/wiki/Customization#list-of-effects
--
-- Green: "\x1b[1;33;49m"
-- Yellow: "\x1b[1;32;49m"
-- Green: "\x1b[1;32;49m"
-- Yellow: "\x1b[1;33;49m"
-- Light Grey: "\x1b[1;30;49m"
-- Prompt Element Colors
uah_color = "\x1b[1;33;49m" -- Green = uah = [user]@[hostname]
cwd_color = "\x1b[1;32;49m" -- Yellow cwd = Current Working Directory
uah_color = "\x1b[1;33;49m" -- Yellow uah = [user]@[hostname]
cwd_color = "\x1b[1;32;49m" -- Green cwd = Current Working Directory
lamb_color = "\x1b[1;30;49m" -- Light Grey = Lambda Color
clean_color = "\x1b[37;1m"
dirty_color = "\x1b[33;3m" -- Yellow, Italic
conflict_color = "\x1b[31;1m" -- Red, Bold
unknown_color = "\x1b[37;1m" -- White = No VCS Status Branch Color
unknown_color = "\x1b[37;1m" -- White, Bold = No VCS Status Branch Color

70
vendor/git-prompt.sh vendored
View File

@ -1,26 +1,35 @@
# Returns 1 if git status for Cmder is disabled, otherwise returns 0
function getGitStatusSetting() {
gitStatusSetting=$(git --no-pager config -l 2>/dev/null)
local gitConfig
if [[ -n ${gitStatusSetting} ]] && [[ ${gitStatusSetting} =~ cmder.status=false ]] || [[ ${gitStatusSetting} =~ cmder.shstatus=false ]]
# 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') ]]
then
echo false
else
echo true
return 1 # disabled
fi
return 0
}
# Prints current branch or detached HEAD short commit hash
function getSimpleGitBranch() {
gitDir=$(git rev-parse --git-dir 2>/dev/null)
if [ -z "$gitDir" ]; then
return 0
fi
local gitDir
gitDir=$(git rev-parse --git-dir 2>/dev/null) || return 0
headContent=$(< "$gitDir/HEAD")
if [[ "$headContent" == "ref: refs/heads/"* ]]
local headFile="$gitDir/HEAD"
[ -f "$headFile" ] || return 0
local headContent
headContent=$(< "$headFile")
if [[ "$headContent" =~ ^ref:\ refs/heads/(.+)$ ]]
then
echo " (${headContent:16})"
echo " (${BASH_REMATCH[1]})"
else
echo " (HEAD detached at ${headContent:0:7})"
echo " (HEAD detached at ${headContent:0:7})"
fi
}
@ -33,18 +42,18 @@ fi
if test -f ~/.config/git/git-prompt.sh
then
if [[ $(getGitStatusSetting) == true ]]
if getGitStatusSetting
then
. ~/.config/git/git-prompt.sh
fi
else
PS1='\[\033]0;$MSYSTEM:${PWD//[^[:ascii:]]/?}\007\]' # set window title
# PS1="$PS1"'\n' # new line
PS1="$PS1"'\[\033[32m\]' # change to green
# Taken parts from https://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)
PS1="$PS1"'\[\033[32m\]' # change to green and bold
PS1="$PS1"'\u@\h ' # user@host<space>
# PS1="$PS1"'\[\033[35m\]' # change to purple
# PS1="$PS1"'$MSYSTEM ' # show MSYSTEM
PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
PS1="$PS1${MSYSTEM:+\[\033[35m\]$MSYSTEM }" # show MSYSTEM in purple (if set)
PS1="$PS1"'\[\033[1;33m\]' # change to dark yellow in bold
PS1="$PS1"'\w' # current working directory
if test -z "$WINELOADERNOEXEC"
then
@ -55,7 +64,7 @@ else
if test -f "$COMPLETION_PATH/git-prompt.sh"
then
. "$COMPLETION_PATH/git-completion.bash"
if [[ $(getGitStatusSetting) == true ]]
if getGitStatusSetting
then
. "$COMPLETION_PATH/git-prompt.sh"
PS1="$PS1"'\[\033[36m\]' # change color to cyan
@ -66,9 +75,22 @@ else
fi
fi
fi
PS1="$PS1"'\[\033[0m\]' # change color
PS1="$PS1"'\[\033[0m\]' # reset color
PS1="$PS1"'\n' # new line
PS1="$PS1"'λ ' # prompt: always λ
PS1="$PS1"'\[\033[30;1m\]' # change color to grey in bold
PS1="$PS1"'λ ' # prompt: Cmder uses λ
PS1="$PS1"'\[\033[0m\]' # reset color
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"
then
for c in "$HOME"/bash_completion.d/*.bash
do
# Handle absence of any scripts (or the folder) gracefully
test ! -f "$c" ||
. "$c"
done
fi

12
vendor/sources.json vendored
View File

@ -1,13 +1,13 @@
[
{
"name": "git-for-windows",
"version": "2.50.1.windows.1",
"url": "https://github.com/git-for-windows/git/releases/download/v2.50.1.windows.1/PortableGit-2.50.1-64-bit.7z.exe"
"version": "2.49.0.windows.1",
"url": "https://github.com/git-for-windows/git/releases/download/v2.49.0.windows.1/PortableGit-2.49.0-64-bit.7z.exe"
},
{
"name": "clink",
"version": "1.7.21",
"url": "https://github.com/chrisant996/clink/releases/download/v1.7.21/clink.1.7.21.9f5af8.zip"
"version": "1.7.14",
"url": "https://github.com/chrisant996/clink/releases/download/v1.7.14/clink.1.7.14.843933.zip"
},
{
"name": "conemu-maximus5",
@ -16,7 +16,7 @@
},
{
"name": "clink-completions",
"version": "0.6.3",
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/v0.6.3.zip"
"version": "0.6.2",
"url": "https://github.com/vladimir-kotikov/clink-completions/archive/v0.6.2.zip"
}
]