Skip to content

davmonk/Prompts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prompts

A collection of matching shell prompts for zsh, bash, and tcsh with a consistent two-line layout and 256-colour styling.

What they look like

┌─[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)

Features

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.

Files

File Shell
prompt.zsh Zsh
prompt.bash Bash
prompt.tcsh Tcsh

Prerequisites

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 (prompt.zsh)

  • zsh 5.0 or later
  • git — optional, needed for branch display

bash (prompt.bash)

  • bash 4.0 or later
  • git — optional, needed for branch display

tcsh (prompt.tcsh)

  • tcsh — any recent version
  • date — used for HH:MM:SS timestamp (pre-installed on all platforms)
  • git — optional, needed for branch display

Installation

Source the appropriate file from your shell's startup file.

zsh

Add to ~/.zshrc:

source /path/to/prompt.zsh

bash

Add to ~/.bashrc (or ~/.bash_profile on macOS):

source /path/to/prompt.bash

tcsh

Add to ~/.tcshrc:

source /path/to/prompt.tcsh

How it works

zsh

Uses add-zsh-hook to attach two hook functions:

  • preexec — records $SECONDS when a command starts
  • precmd — calculates elapsed time and sets _cmd_duration before 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.

bash

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.

tcsh

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.

About

repository for improved prompts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages