It might be too noisy for some, but here's some custom prompt code that helps show OS/Host/Git Context/Error level/Subshell Depth.
Preview with commands to display the status bits
In tcstart.btm
Library Code:
Preview with commands to display the status bits
In tcstart.btm
library /r %ROOT\library
prompt %%@execstr[BuildPrompt %%?]
Library Code:
BuildPrompt {
@echo off
setlocal
set LASTEXITCODE=%1
set CYAN=$e[36;1;44m
set WHITE=$e[m$e[97;44m
set GREEN=$e[32;1;44m
set RED=$e[1;91;44m
set YELLOW=$e[1;93;44m
set HOST=%[HOSTNAME]
rem in case no default already set
iff %HOST == "" then
set HOST=%@lower[%_winname]
endiff
iff %_elevated then
rem Mark in red since we a sudo/root
set HOST=%[RED]%[HOST]
endiff
set EXITSTATUS=
iff %[LASTEXITCODE] then
rem Show the return status in red if last command failed
set EXITSTATUS= %[RED](%[LASTEXITCODE])
endiff
set SUBSHELL=
iff %[_SHELL] then
rem If not the main shell, show shell depth in yellow
set SUBSHELL= %[YELLOW](%%[_SHELL])
endiff
rem Uh...There's got to be a better way. Show relevent git repo in green
set GITREPO=`[%@name[%@execstr[git config --get remote.origin.url 2>nul:]]`
set GITBRANCH=`%@execstr[git branch --show-current 2>nul:]]`
set GITINFO=%[GREEN]%[GITREPO]/%[GITBRANCH]
rem UNAME is set to 'Windows', Because with WSL 'hostname' isn't quite enough anymore
set OSHOST=%[CYAN][%OS/%HOST]
rem current date and time
set DATETIME=%[WHITE]$d, $T
echo %[OSHOST] %[DATETIME]%[SUBSHELL]%[EXITSTATUS]$_%[GITINFO] %[WHITE]$~\
endlocal
}