A collection of matching shell prompts for zsh, bash, and tcsh with a consistent two-line layout and 256-colour styling.
┌─[14:32:05]─[hostname]─[~/path/to/dir]─[ main]
└─ ❯ [ 3s]
- Line 1: time, hostname, current directory, git branch (when in a repo)
- Line 2: prompt symbol (
❯for normal users,#for root) - Right side: command duration (shown only when ≥ 1 second)
| Feature | zsh | bash | tcsh |
|---|---|---|---|
| Current time (HH:MM:SS) | ✓ | ✓ | ✓ |
| Hostname | ✓ | ✓ | ✓ |
| Current directory | ✓ | ✓ | ✓ |
| Git branch / commit hash | ✓ | ✓ | ✓ |
| Command duration | ✓ | ✓ | ✓ |
Root indicator (#) |
✓ | ✓ | ✓ |
| Duration on right side (RPROMPT) | ✓ | — | — |
The zsh version shows duration in RPROMPT (right-aligned). The bash version embeds it inline on the second line. The tcsh version uses the built-in time variable to print duration after commands that take ≥ 1 second.
| File | Shell |
|---|---|
prompt.zsh |
Zsh |
prompt.bash |
Bash |
prompt.tcsh |
Tcsh |
A terminal emulator that supports 256-colour ANSI escape codes and UTF-8 (required for the ❯ symbol and box-drawing characters). All modern terminal emulators qualify.
- zsh 5.0 or later
git— optional, needed for branch display
- bash 4.0 or later
git— optional, needed for branch display
- tcsh — any recent version
date— used forHH:MM:SStimestamp (pre-installed on all platforms)git— optional, needed for branch display
Source the appropriate file from your shell's startup file.
Add to ~/.zshrc:
source /path/to/prompt.zshAdd to ~/.bashrc (or ~/.bash_profile on macOS):
source /path/to/prompt.bashAdd to ~/.tcshrc:
source /path/to/prompt.tcshUses add-zsh-hook to attach two hook functions:
preexec— records$SECONDSwhen a command startsprecmd— calculates elapsed time and sets_cmd_durationbefore each prompt render
The git segment is generated by a function called inline via PROMPT_SUBST. Duration appears in RPROMPT and is only shown when elapsed time is ≥ 1 second.
Uses PROMPT_COMMAND to rebuild PS1 before each prompt. Command timing is tracked via a trap ... DEBUG that fires before each command. The git branch is resolved with git symbolic-ref (branches) falling back to git rev-parse (detached HEAD). Duration is embedded inline on the second line since bash has no RPROMPT.
Uses the built-in time variable to automatically print duration for commands that take ≥ 1 second — no manual timing needed. The prompt is rebuilt in a precmd alias that calls date for the timestamp and git symbolic-ref/git rev-parse for the branch. Tcsh has no preexec, so per-command timing relies entirely on the built-in mechanism.