Skip to content
Sindre Sorhus edited this page Jul 17, 2017 · 37 revisions

Customizations

Use different prompt symbol for non-zero exit codes

By default, pure only changes the color of the prompt symbol. You can change this behavior by modifying PROMPT after pure has been initialized in your .zshrc.

.zshrc:

prompt pure
PROMPT='%(?.%F{magenta}△.%F{red}▲)%f '

The above change would show a magenta character by default, and a red when there is a non-zero exit status. This works because pure initialised PROMPT only once, so you are free to modify it afterwards.

Show exit code of last command as a separate prompt character

The prompt character still turns red if the last command didn't exit with 0, but adds another magenta to show that it was the previous command that failed.

Replace: PROMPT='%(?.%F{magenta}.%F{red})❯%f '

With: PROMPT='%(?.%F{magenta}.%F{red}❯%F{magenta})❯%f '

Show current mode when using vi keybindings

Prompt screenshot

Add in prompt_pure_setup()

zstyle ':prezto:module:editor:info:keymap:primary'   format "❯%f"
zstyle ':prezto:module:editor:info:keymap:alternate' format "❮%f"

and change the PROMPT line to

PROMPT='%(?.%F{magenta}.%F{red})${editor_info[keymap]} '

It works using prezto, still looking for a generic solution

A generic way of showing current mode in vi mode

Following this guide I got the mode prompt without Prezto.

VIM_PROMPT="❯"
PROMPT='%(?.%F{magenta}.%F{red})${VIM_PROMPT}%f '

prompt_pure_update_vim_prompt() {
    zle || {
        print "error: pure_update_vim_prompt must be called when zle is active"
        return 1
    }
    VIM_PROMPT=${${KEYMAP/vicmd/❮}/(main|viins)/❯}
    zle .reset-prompt
}

function zle-line-init zle-keymap-select { 
    prompt_pure_update_vim_prompt
}
zle -N zle-line-init
zle -N zle-keymap-select

Put all of this code to your .zshrc or, if you do not wish to replace your zle-line-init and zle-keymap-select functions, you can choose to call prompt_pure_update_vim_prompt from them.

Safer symbols

Pure's default symbols are cool, but if you use a limited font such as Inconsolata (because hey, it does look good), you'll need to change them. These worked for me on Windows:

PURE_PROMPT_SYMBOL='»'
PURE_GIT_DOWN_ARROW=''
PURE_GIT_UP_ARROW=''

Show system time in prompt

To show the current system time before the prompt symbol like

Screenshot

Initialize pure with:

prompt pure
PROMPT='%F{white}%* '$PROMPT

Alternatively you can set RPROMPT='%F{white}%*' beforehand.

Create aliases for really long directory paths

Let's face it, a really long directory path hurts readability and can easily be aliased to something much more meaningful. Pure provides no such functionality, however, Zsh does!

By enabling the Zsh option for named directories (setopt AUTO_NAME_DIRS) we can alias directories by assigning them to a variable.

An example .zshrc with one aliased directory (SUPERSECRET):

setopt AUTO_NAME_DIRS
SUPERSECRET=$HOME/a/really/long/path/to/my/SecretProject

prompt pure

And here's the result:

~cd $SUPERSECRET

~SUPERSECRETpwd
/Users/myuser/a/really/long/path/to/my/SecretProject

As a bonus, you can enable cdable variables (setopt CDABLE_VARS). This allows us to omit the $ when cding into the directory. We can now simply cd SUPERSECRET.

Inspired

@sapegin’s Bash Prompt

Prompt screenshot

Bash prompt and color theme for Terminal.app.

@brandonweiss’s Fish Prompt

Screenshot of Pure.fish

Pure.fish is a Pure-inspired prompt for fish shell.

@therealklanni's Purity fork

Screenshot of Pure.fish

Purity is my own spin on Pure. It favors a more compact current working directory, important details on the main prompt line, and extra Git indicators (modified, staged, deleted, renamed, unmerged, and untracked items) in addition to the unique features of Pure (namely: the "pull ready" indicator and execution time feedback).

@rafaelrinaldi's Fish Prompt

pure is a direct port of the original pure theme to fish shell.

It's fast and implements all the features available on the original version, including symbols, colors and indicators (Git repository info, previous command execution time with threshold, and so on).

Although the screenshot shows a light Terminal theme, it also works well with dark themes.

Free to open an issue to help me improve the theme.

Clone this wiki locally