Created
October 26, 2025 19:47
-
-
Save chris-piekarski/e1061c9a7e0d095683da8a99fa274530 to your computer and use it in GitHub Desktop.
PROMPT_COMMAND
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export PROMPT_COMMAND=' | |
| # Get relative path (~ instead of /home/user) | |
| relpath=$PWD | |
| case "$relpath" in | |
| $HOME*) relpath="~${relpath#$HOME}";; | |
| esac | |
| [ ${#relpath} -gt 30 ] && relpath="…${relpath: -30}" | |
| # Get current git branch if inside a repo | |
| branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) | |
| # Get timestamp (HH:MM:SS) | |
| timestamp=$(date +"%H:%M:%S") | |
| # Choose separator based on branch presence | |
| sep=":" | |
| [ -n "$branch" ] && sep="·" | |
| # Build and print tab title | |
| printf "\033]0;%s%s%s%s [%s]\007" \ | |
| "$(hostname)" "$sep" "$relpath" \ | |
| "${branch:+ ($branch)}" "$timestamp" | |
| ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment