A prompt with the information you need the moment you need it.
NEW: It's been a long time coming but I've added gifs so you can see what the fuss is all about!
I designed my prompt for readability and to present useful information when needed.
The Garrett prompt supports:
git
status information- All prompt types (
PS1
-PS4
,Autocorrection
, and a backupSUDO_PS1
) - Notification of background jobs
- Non-zero return codes
- Line drawing
ssh
status- Directory truncation
- Vi-editor info
- Job completion
- History line number
- The current time
Many (most?) prompts put the directory information in front of the cursor entry point. Changing directories changes the location of the cursor on the screen. This inconsistent location is undesirable. The Garrett prompt cursor is consistently at the same place on the screen.
By using line drawing and inserting a newline between each command, scrolling back through your history for the output of a previous command becomes drastically easier.
Both Terminal and iTerm2 support line drawing and the prompt will look it's best there.
The Garrett prompt has a fallback if line drawing is unsupported by your terminal emulator.
The terminal theme shown here is Solarized Dark and the font is Pragmata Pro (affiliate link).
The right prompt contains useful information but moves out of the way for long commands.
NOTE: This view contains both the selection and continuation prompts. The selection prompt is shown when entering 1, 2, or 3.
There is a backup root prompt that will highlight most of the terminal in red if you switch to the sudo user inside another shell which hasn't set this prompt. It's a simple safety measure.
NOTE: This feature is available only when the shell environment is not reset by
switching to the sudo
command. i.e., switch to root using sudo -s
and you
will see the prompt change its primary color to red (as described above); switch
to root with sudo -i
, the environment will be reset and you'll see the base
Zsh prompt instead of my custom one.
This prompt has the following features. These features may be disabled and rearranged as desired by using the corresponding tokens. There are also minor changes that can (easily) be made in terms of formatting the output of the prompt by editing the prompt file itself but that's up to you.
You can display either the full or truncated hostname on ssh by editing the prompt file. The default is to display the truncated hostname.
NOTE: The primary prompt color changes from gray to orange—color was lost when making the gif (#1).
As a safety feature, the prompt will change color when logged in as the root user. This looks the same as host color change on ssh but with a red color instead of orange.
Directory truncation will slim down the PWD
to the first letter of each child
directory. This is configurable via Prezto.
Support for non-zero return codes must be enabled. See Prezto's prompt documentation.
You can change to time format from within the prompt file. Available options:
- 24 hour time format (default)
- 24 hour time format, second precise
- AM/PM time format
Useful for bang history completion and hipster pride.
Symbol | Meaning |
---|---|
λ:master | branch |
9769ee9 | commit hash |
| | dirty |
⬆ | ahead |
⬇ | behind |
⥮ | diverged |
✭ | stashed |
✚ | added |
✗ | deleted |
✱ | modified |
➜ | renamed |
═ | unmerged |
◼ | untracked |
Normal mode:
Overwrite mode:
If you like, you can add notification of insert mode by editing the prompt.
The default time is 2 seconds but is adjustable in the code.
- Have a working installation of Prezto
- Copy
prompt_garrett_setup
to~/.zprezto/modules/prompt/functions/
- Set
zstyle ':prezto:module:prompt' theme 'garrett'
in~/.zpreztorc
- Optionally, configure pwd trunctation
- Open a new terminal window
If you'd rather not have to do this, please provide your support on Prezto #914.
Here's helpful suggestions and tips for ensuring the prompt works at its best.
- Make sure you're using Prezto with the git module enabled - the prompt won't work without it (see #6, #7)!
- Even better, use my fork of Prezto which includes modifications (mentioned above) for a better experience
- The Garrett prompt has a custom
clear-screen
widget so that^L
will properly redraw the prompt (#5). If you use zsh-syntax-highlighting, zsh-history-substring-search, or zsh-autosuggestions, be sure to load those after you load the prompt in your dotfiles.
If you've found this project useful, would you consider sending your support?
The author of this module should be contacted via the issue tracker.
Chauncey Garrett |