Good terminal prefix (pats head)
i do the following to be more efficient:
# Allow $VAR and $(cmd) in PROMPT
setopt prompt_subst
# ---------------------------------------------------------------
# DATE / TIME
# ---------------------------------------------------------------
PROMPT_DATETIME='%D{%b %d %H:%M:%S}'
# '%D{%Y-%m-%d %H:%M:%S}'
# ---------------------------------------------------------------
# EXIT CODE INDICATOR (shows only when nonzero)
# ---------------------------------------------------------------
PROMPT_EXIT='%(?..[%?])'
# ---------------------------------------------------------------
# COMMAND TIMING (built-in; prints for cmds > 2s)
# ---------------------------------------------------------------
REPORTTIME=2
# ---------------------------------------------------------------
# PYTHON VIRTUALENV INDICATOR (shows only if active)
# If you don't want the default "(venv)" that virtualenv adds,
# also set: export VIRTUAL_ENV_DISABLE_PROMPT=1
# ---------------------------------------------------------------
PROMPT_VENV='${VIRTUAL_ENV:+(${${VIRTUAL_ENV:t}})}'
# ---------------------------------------------------------------
# DIRECTORY SHORTENING (fish-style-ish)
# compress middle dirs to their first letter
# ---------------------------------------------------------------
shorten_path () {
local P=$1
local -a parts
parts=("${(s:/:)P}")
if (( ${#parts[@]} > 3 )); then
# first / compressed middle / last
print -r "${parts[1]}/${(j:/:)${parts[2,-2]/(#m)?*/${MATCH[1]}}}/${parts[-1]}"
else
print -r "$P"
fi
}
PROMPT_PWD='%~'
# PROMPT_PWD='$(shorten_path $PWD)'
# ---------------------------------------------------------------
# JOB COUNT (background jobs)
# ---------------------------------------------------------------
PROMPT_JOBS='%(1j.[%j job(s)].)'
# ---------------------------------------------------------------
# PURE-GIT INDICATORS (no external tools)
# branch name, dirtiness, staged, unstaged, untracked flags
# ---------------------------------------------------------------
git_prompt () {
local branch staged unstaged untracked dirty
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) || return 0
staged=$(git diff --cached --name-status 2>/dev/null | wc -l | tr -d ' ')
unstaged=$(git diff --name-status 2>/dev/null | wc -l | tr -d ' ')
untracked=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d ' ')
dirty=""
(( staged > 0 )) && dirty+="+" # staged
(( unstaged > 0 )) && dirty+="*" # unstaged
(( untracked > 0 )) && dirty+="?" # untracked
print -r "[$branch$dirty]"
}
PROMPT_GIT='$(git_prompt)'
# ---------------------------------------------------------------
# FINAL PROMPT
# ---------------------------------------------------------------
PROMPT="${PROMPT_DATETIME} ${PROMPT_EXIT} ${PROMPT_VENV} ${PROMPT_PWD} ${PROMPT_JOBS} ${PROMPT_GIT} %# "
(venv) Feb 28 12:22:44 (venv) ~/repos/homemade_benchmark_tests %
Subscribe to:
Post Comments (Atom)
Asymmetric loss functions over budget -- evaluation considerations
The Core Philosophical Tension What you're describing is an asymmetric loss function over budget. The intuition is: - If the ...
-
A name indicates what we seek. An address indicates where it is. A route indicates how to get there. The internet protocol deals prima...
-
Pattern Description Dogfooding: Creators use their own software heavily, improving it organically. “Thin to Thick” Clients: Many succes...
-
On March 4, 2025, the New York Times shut down its .onion site which it had launched in 2017. Is tor dead? tor published metrics speak to a ...
No comments:
Post a Comment