Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional prompt prefix if root #378

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pure.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,11 @@ prompt_pure_setup() {
# if a virtualenv is activated, display it in grey
PROMPT='%(12V.%F{242}%12v%f .)'

# if PURE_ROOT_HASH is set and we are root then prefix prompt with a red hash '#'
if (( ${PURE_ROOT_HASH:0} )) && [[ $UID -eq 0 ]]; then
PROMPT+='%F{red}# '
fi

# prompt turns red if the previous command didn't exit with 0
PROMPT+='%(?.%F{magenta}.%F{red})${PURE_PROMPT_SYMBOL:-❯}%f '
}
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ Defines the git down arrow symbol. The default value is `⇣`.

Defines the git up arrow symbol. The default value is `⇡`.

### `PURE_ROOT_HASH`

Set `PURE_ROOT_HASH=1` to prefix prompt with a red `#` if we are root.

## Example

```sh
Expand Down