mirror of
https://github.com/akelge/zsh
synced 2025-07-04 13:39:07 +00:00
Added original pure and renamed pure to mypure
This commit is contained in:
12
zsh.d/prompts/pure/.editorconfig
Normal file
12
zsh.d/prompts/pure/.editorconfig
Normal file
@ -0,0 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
1
zsh.d/prompts/pure/.gitattributes
vendored
Normal file
1
zsh.d/prompts/pure/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
1
zsh.d/prompts/pure/.github/funding.yml
vendored
Normal file
1
zsh.d/prompts/pure/.github/funding.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
github: sindresorhus
|
48
zsh.d/prompts/pure/.github/issue_template.md
vendored
Normal file
48
zsh.d/prompts/pure/.github/issue_template.md
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<!-- TIP: Hit 'Preview' for a more readable version of this template -->
|
||||
|
||||
### General information
|
||||
|
||||
#### System report (output of `prompt_pure_system_report`):
|
||||
|
||||
<!-- TIP: Run `prompt_pure_system_report | pbcopy` on macOS to copy straight to clipboard, then paste here -->
|
||||
|
||||
#### Other information
|
||||
|
||||
<!--
|
||||
If you can't load Pure to create a system report, please report the following information:
|
||||
|
||||
- Pure version: 1.x.x
|
||||
- ZSH version: 5.x.x
|
||||
- Terminal program & version: (e.g. Hyper 1.0.0, iTerm 3.0.0, xterm 327, other?)
|
||||
- Operating system: (e.g. macOS Mojave 10.13.1)
|
||||
- ZSH framework: (e.g. oh-my-zsh, prezto, antigen, antibody, zplug, other?)
|
||||
-->
|
||||
|
||||
#### I have:
|
||||
|
||||
- [ ] Tested with another terminal program and can reproduce the issue: <!-- e.g. iTerm, etc. -->
|
||||
- [ ] Followed the [integration](https://github.com/sindresorhus/pure#integration) instructions for my framework
|
||||
|
||||
### Problem description
|
||||
|
||||
|
||||
|
||||
### Reproduction steps
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### My `.zshrc`:
|
||||
|
||||
<!--
|
||||
Please provide a minimal `.zshrc` that reproduces the issue.
|
||||
Try to remove everything that that does not affect the issue, the fewer lines, the better.
|
||||
|
||||
Example:
|
||||
|
||||
```shell
|
||||
autoload -U promptinit; promptinit
|
||||
prompt pure
|
||||
```
|
||||
-->
|
1
zsh.d/prompts/pure/.npmrc
Normal file
1
zsh.d/prompts/pure/.npmrc
Normal file
@ -0,0 +1 @@
|
||||
package-lock=false
|
26
zsh.d/prompts/pure/arch/PKGBUILD
Normal file
26
zsh.d/prompts/pure/arch/PKGBUILD
Normal file
@ -0,0 +1,26 @@
|
||||
# Author: Sindre Sorhus
|
||||
# Maintainer: Pat Brisbin <pbrisbin@gmail.com>
|
||||
# Contributor: Emil Falk <emph@emph.se>
|
||||
pkgname=zsh-pure-prompt-git
|
||||
pkgver=r61.7d3b317
|
||||
pkgrel=1
|
||||
pkgdesc='A minimal and pure prompt for zsh.'
|
||||
arch=('any')
|
||||
url='https://github.com/sindresorhus/pure'
|
||||
license=('MIT')
|
||||
depends=('zsh' 'git')
|
||||
source=("$pkgname::git://github.com/sindresorhus/pure.git")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd $srcdir/$pkgname
|
||||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
package() {
|
||||
cd $srcdir/$pkgname
|
||||
install -Dm644 pure.zsh \
|
||||
"$pkgdir/usr/share/zsh/functions/Prompts/prompt_pure_setup"
|
||||
install -Dm644 async.zsh \
|
||||
"$pkgdir/usr/share/zsh/functions/async"
|
||||
}
|
@ -3,12 +3,12 @@
|
||||
#
|
||||
# zsh-async
|
||||
#
|
||||
# version: 1.7.2
|
||||
# version: 1.8.0
|
||||
# author: Mathias Fredriksson
|
||||
# url: https://github.com/mafredri/zsh-async
|
||||
#
|
||||
|
||||
typeset -g ASYNC_VERSION=1.7.2
|
||||
typeset -g ASYNC_VERSION=1.8.0
|
||||
# Produce debug output from zsh-async when set to 1.
|
||||
typeset -g ASYNC_DEBUG=${ASYNC_DEBUG:-0}
|
||||
|
||||
@ -37,19 +37,27 @@ _async_job() {
|
||||
# block, after the command block has completed, the stdin for `cat` is
|
||||
# closed, causing stderr to be appended with a $'\0' at the end to mark the
|
||||
# end of output from this job.
|
||||
local jobname=${ASYNC_JOB_NAME:-$1}
|
||||
local stdout stderr ret tok
|
||||
{
|
||||
stdout=$(eval "$@")
|
||||
ret=$?
|
||||
duration=$(( EPOCHREALTIME - duration )) # Calculate duration.
|
||||
local jobname=${ASYNC_JOB_NAME:-$1} out
|
||||
out="$(
|
||||
local stdout stderr ret tok
|
||||
{
|
||||
stdout=$(eval "$@")
|
||||
ret=$?
|
||||
duration=$(( EPOCHREALTIME - duration )) # Calculate duration.
|
||||
|
||||
# Grab mutex lock, stalls until token is available.
|
||||
read -r -k 1 -p tok || exit 1
|
||||
print -r -n - $'\0'${(q)jobname} $ret ${(q)stdout} $duration
|
||||
} 2> >(stderr=$(cat) && print -r -n - " "${(q)stderr}$'\0')
|
||||
)"
|
||||
if [[ $out != $'\0'*$'\0' ]]; then
|
||||
# Corrupted output (aborted job?), skipping.
|
||||
return
|
||||
fi
|
||||
|
||||
# Return output (<job_name> <return_code> <stdout> <duration> <stderr>).
|
||||
print -r -n - $'\0'${(q)jobname} $ret ${(q)stdout} $duration
|
||||
} 2> >(stderr=$(cat) && print -r -n - " "${(q)stderr}$'\0')
|
||||
# Grab mutex lock, stalls until token is available.
|
||||
read -r -k 1 -p tok || return 1
|
||||
|
||||
# Return output (<job_name> <return_code> <stdout> <duration> <stderr>).
|
||||
print -r -n - "$out"
|
||||
|
||||
# Unlock mutex by inserting a token.
|
||||
print -n -p $tok
|
||||
@ -73,10 +81,13 @@ _async_worker() {
|
||||
# When a zpty is deleted (using -d) all the zpty instances created before
|
||||
# the one being deleted receive a SIGHUP, unless we catch it, the async
|
||||
# worker would simply exit (stop working) even though visible in the list
|
||||
# of zpty's (zpty -L).
|
||||
TRAPHUP() {
|
||||
return 0 # Return 0, indicating signal was handled.
|
||||
}
|
||||
# of zpty's (zpty -L). This has been fixed around the time of Zsh 5.4
|
||||
# (not released).
|
||||
if ! is-at-least 5.4.1; then
|
||||
TRAPHUP() {
|
||||
return 0 # Return 0, indicating signal was handled.
|
||||
}
|
||||
fi
|
||||
|
||||
local -A storage
|
||||
local unique=0
|
||||
@ -121,15 +132,33 @@ _async_worker() {
|
||||
# Register a SIGCHLD trap to handle the completion of child processes.
|
||||
trap child_exit CHLD
|
||||
|
||||
# Process option parameters passed to worker
|
||||
while getopts "np:u" opt; do
|
||||
# Process option parameters passed to worker.
|
||||
while getopts "np:uz" opt; do
|
||||
case $opt in
|
||||
n) notify_parent=1;;
|
||||
p) parent_pid=$OPTARG;;
|
||||
u) unique=1;;
|
||||
z) notify_parent=0;; # Uses ZLE watcher instead.
|
||||
esac
|
||||
done
|
||||
|
||||
# Terminate all running jobs, note that this function does not
|
||||
# reinstall the child trap.
|
||||
terminate_jobs() {
|
||||
trap - CHLD # Ignore child exits during kill.
|
||||
coproc : # Quit coproc.
|
||||
coproc_pid=0 # Reset pid.
|
||||
|
||||
if is-at-least 5.4.1; then
|
||||
trap '' HUP # Catch the HUP sent to this process.
|
||||
kill -HUP -$$ # Send to entire process group.
|
||||
trap - HUP # Disable HUP trap.
|
||||
else
|
||||
# We already handle HUP for Zsh < 5.4.1.
|
||||
kill -HUP -$$ # Send to entire process group.
|
||||
fi
|
||||
}
|
||||
|
||||
killjobs() {
|
||||
local tok
|
||||
local -a pids
|
||||
@ -143,9 +172,8 @@ _async_worker() {
|
||||
# process is in the middle of writing to stdin during kill.
|
||||
(( coproc_pid )) && read -r -k 1 -p tok
|
||||
|
||||
kill -HUP -$$ # Send to entire process group.
|
||||
coproc : # Quit coproc.
|
||||
coproc_pid=0 # Reset pid.
|
||||
terminate_jobs
|
||||
trap child_exit CHLD # Reinstall child trap.
|
||||
}
|
||||
|
||||
local request do_eval=0
|
||||
@ -153,17 +181,27 @@ _async_worker() {
|
||||
while :; do
|
||||
# Wait for jobs sent by async_job.
|
||||
read -r -d $'\0' request || {
|
||||
# Since we handle SIGHUP above (and thus do not know when `zpty -d`)
|
||||
# occurs, a failure to read probably indicates that stdin has
|
||||
# closed. This is why we propagate the signal to all children and
|
||||
# exit manually.
|
||||
kill -HUP -$$ # Send SIGHUP to all jobs.
|
||||
exit 0
|
||||
# Unknown error occurred while reading from stdin, the zpty
|
||||
# worker is likely in a broken state, so we shut down.
|
||||
terminate_jobs
|
||||
|
||||
# Stdin is broken and in case this was an unintended
|
||||
# crash, we try to report it as a last hurrah.
|
||||
print -r -n $'\0'"'[async]'" $(( 127 + 3 )) "''" 0 "'$0:$LINENO: zpty fd died, exiting'"$'\0'
|
||||
|
||||
# We use `return` to abort here because using `exit` may
|
||||
# result in an infinite loop that never exits and, as a
|
||||
# result, high CPU utilization.
|
||||
return $(( 127 + 1 ))
|
||||
}
|
||||
|
||||
# We need to clean the input here because sometimes when a zpty
|
||||
# has died and been respawned, messages will be prefixed with a
|
||||
# carraige return (\r, or \C-M).
|
||||
request=${request#$'\C-M'}
|
||||
|
||||
# Check for non-job commands sent to worker
|
||||
case $request in
|
||||
_unset_trap) notify_parent=0; continue;;
|
||||
_killjobs) killjobs; continue;;
|
||||
_async_eval*) do_eval=1;;
|
||||
esac
|
||||
@ -175,9 +213,11 @@ _async_worker() {
|
||||
# Name of the job (first argument).
|
||||
local job=$cmd[1]
|
||||
|
||||
# If worker should perform unique jobs
|
||||
if (( unique )); then
|
||||
# Check if a previous job is still running, if yes, let it finnish
|
||||
# Check if a worker should perform unique jobs, unless
|
||||
# this is an eval since they run synchronously.
|
||||
if (( !do_eval )) && (( unique )); then
|
||||
# Check if a previous job is still running, if yes,
|
||||
# skip this job and let the previous one finish.
|
||||
for pid in ${${(v)jobstates##*:*:}%\=*}; do
|
||||
if [[ ${storage[$job]} == $pid ]]; then
|
||||
continue 2
|
||||
@ -317,7 +357,7 @@ _async_zle_watcher() {
|
||||
async_stop_worker $worker
|
||||
|
||||
if [[ -n $callback ]]; then
|
||||
$callback '[async]' 2 "" 0 "$worker:zle -F $1 returned error $2" 0
|
||||
$callback '[async]' 2 "" 0 "$0:$LINENO: error: fd for $worker failed: zle -F $1 returned error $2" 0
|
||||
fi
|
||||
return
|
||||
fi;
|
||||
@ -327,6 +367,28 @@ _async_zle_watcher() {
|
||||
fi
|
||||
}
|
||||
|
||||
_async_send_job() {
|
||||
setopt localoptions noshwordsplit noksharrays noposixidentifiers noposixstrings
|
||||
|
||||
local caller=$1
|
||||
local worker=$2
|
||||
shift 2
|
||||
|
||||
zpty -t $worker &>/dev/null || {
|
||||
typeset -gA ASYNC_CALLBACKS
|
||||
local callback=$ASYNC_CALLBACKS[$worker]
|
||||
|
||||
if [[ -n $callback ]]; then
|
||||
$callback '[async]' 3 "" 0 "$0:$LINENO: error: no such worker: $worker" 0
|
||||
else
|
||||
print -u2 "$caller: no such async worker: $worker"
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
zpty -w $worker "$@"$'\0'
|
||||
}
|
||||
|
||||
#
|
||||
# Start a new asynchronous job on specified worker, assumes the worker is running.
|
||||
#
|
||||
@ -344,8 +406,7 @@ async_job() {
|
||||
cmd=(${(q)cmd}) # Quote special characters in multi argument commands.
|
||||
fi
|
||||
|
||||
# Quote the cmd in case RC_EXPAND_PARAM is set.
|
||||
zpty -w $worker "$cmd"$'\0'
|
||||
_async_send_job $0 $worker "$cmd"
|
||||
}
|
||||
|
||||
#
|
||||
@ -369,7 +430,7 @@ async_worker_eval() {
|
||||
fi
|
||||
|
||||
# Quote the cmd in case RC_EXPAND_PARAM is set.
|
||||
zpty -w $worker "_async_eval $cmd"$'\0'
|
||||
_async_send_job $0 $worker "_async_eval $cmd"
|
||||
}
|
||||
|
||||
# This function traps notification signals and calls all registered callbacks
|
||||
@ -392,7 +453,7 @@ _async_notify_trap() {
|
||||
async_register_callback() {
|
||||
setopt localoptions noshwordsplit nolocaltraps
|
||||
|
||||
typeset -gA ASYNC_CALLBACKS
|
||||
typeset -gA ASYNC_PTYS ASYNC_CALLBACKS
|
||||
local worker=$1; shift
|
||||
|
||||
ASYNC_CALLBACKS[$worker]="$*"
|
||||
@ -401,6 +462,14 @@ async_register_callback() {
|
||||
# workers to notify (via -n) when a job is done.
|
||||
if [[ ! -o interactive ]] || [[ ! -o zle ]]; then
|
||||
trap '_async_notify_trap' WINCH
|
||||
elif [[ -o interactive ]] && [[ -o zle ]]; then
|
||||
local fd w
|
||||
for fd w in ${(@kv)ASYNC_PTYS}; do
|
||||
if [[ $w == $worker ]]; then
|
||||
zle -F $fd _async_zle_watcher # Register the ZLE handler.
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
@ -465,6 +534,8 @@ async_start_worker() {
|
||||
setopt localoptions noshwordsplit
|
||||
|
||||
local worker=$1; shift
|
||||
local -a args
|
||||
args=("$@")
|
||||
zpty -t $worker &>/dev/null && return
|
||||
|
||||
typeset -gA ASYNC_PTYS
|
||||
@ -478,15 +549,21 @@ async_start_worker() {
|
||||
unsetopt xtrace
|
||||
}
|
||||
|
||||
if (( ! ASYNC_ZPTY_RETURNS_FD )) && [[ -o interactive ]] && [[ -o zle ]]; then
|
||||
# When zpty doesn't return a file descriptor (on older versions of zsh)
|
||||
# we try to guess it anyway.
|
||||
integer -l zptyfd
|
||||
exec {zptyfd}>&1 # Open a new file descriptor (above 10).
|
||||
exec {zptyfd}>&- # Close it so it's free to be used by zpty.
|
||||
if [[ -o interactive ]] && [[ -o zle ]]; then
|
||||
# Inform the worker to ignore the notify flag and that we're
|
||||
# using a ZLE watcher instead.
|
||||
args+=(-z)
|
||||
|
||||
if (( ! ASYNC_ZPTY_RETURNS_FD )); then
|
||||
# When zpty doesn't return a file descriptor (on older versions of zsh)
|
||||
# we try to guess it anyway.
|
||||
integer -l zptyfd
|
||||
exec {zptyfd}>&1 # Open a new file descriptor (above 10).
|
||||
exec {zptyfd}>&- # Close it so it's free to be used by zpty.
|
||||
fi
|
||||
fi
|
||||
|
||||
zpty -b $worker _async_worker -p $$ $@ || {
|
||||
zpty -b $worker _async_worker -p $$ $args || {
|
||||
async_stop_worker $worker
|
||||
return 1
|
||||
}
|
||||
@ -494,7 +571,7 @@ async_start_worker() {
|
||||
# Re-enable it if it was enabled, for debugging.
|
||||
(( has_xtrace )) && setopt xtrace
|
||||
|
||||
if [[ $ZSH_VERSION < 5.0.8 ]]; then
|
||||
if ! is-at-least 5.0.8; then
|
||||
# For ZSH versions older than 5.0.8 we delay a bit to give
|
||||
# time for the worker to start before issuing commands,
|
||||
# otherwise it will not be ready to receive them.
|
||||
@ -506,11 +583,7 @@ async_start_worker() {
|
||||
REPLY=$zptyfd # Use the guessed value for the file desciptor.
|
||||
fi
|
||||
|
||||
ASYNC_PTYS[$REPLY]=$worker # Map the file desciptor to the worker.
|
||||
zle -F $REPLY _async_zle_watcher # Register the ZLE handler.
|
||||
|
||||
# Disable trap in favor of ZLE handler when notify is enabled (-n).
|
||||
async_job $worker _unset_trap
|
||||
ASYNC_PTYS[$REPLY]=$worker # Map the file desciptor to the worker.
|
||||
fi
|
||||
}
|
||||
|
||||
@ -556,6 +629,9 @@ async_init() {
|
||||
zmodload zsh/zpty
|
||||
zmodload zsh/datetime
|
||||
|
||||
# Load is-at-least for reliable version check.
|
||||
autoload -Uz is-at-least
|
||||
|
||||
# Check if zsh/zpty returns a file descriptor or not,
|
||||
# shell must also be interactive with zle enabled.
|
||||
typeset -g ASYNC_ZPTY_RETURNS_FD=0
|
||||
|
9
zsh.d/prompts/pure/license
Normal file
9
zsh.d/prompts/pure/license
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
42
zsh.d/prompts/pure/package.json
Normal file
42
zsh.d/prompts/pure/package.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "pure-prompt",
|
||||
"version": "1.12.0",
|
||||
"description": "Pretty, minimal and fast ZSH prompt",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/pure",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Mathias Fredriksson",
|
||||
"url": "https://github.com/mafredri"
|
||||
}
|
||||
],
|
||||
"scripts": {
|
||||
"postinstall": "PURE_DEST=/usr/local/share/zsh/site-functions npm run --silent postinstall-link && exit 0; PURE_DEST=\"$PWD/functions\" npm run postinstall-link && npm run postinstall-fail-instructions",
|
||||
"postinstall-link": "mkdir -p \"$PURE_DEST\" && ln -sf \"$PWD/pure.zsh\" \"$PURE_DEST/prompt_pure_setup\" && ln -sf \"$PWD/async.zsh\" \"$PURE_DEST/async\"",
|
||||
"postinstall-fail-instructions": "echo \"ERROR: Could not automagically symlink the prompt. Either:\\n1. Check out the readme on how to do it manually: https://github.com/sindresorhus/pure#manually\\n2. Or add the following to your \\`.zshrc\\`:\\n\\n fpath+=('$PWD/functions')\""
|
||||
},
|
||||
"files": [
|
||||
"pure.zsh",
|
||||
"async.zsh"
|
||||
],
|
||||
"keywords": [
|
||||
"zsh",
|
||||
"zshell",
|
||||
"sh",
|
||||
"shell",
|
||||
"bash",
|
||||
"pure",
|
||||
"prompt",
|
||||
"theme",
|
||||
"git",
|
||||
"async",
|
||||
"fast",
|
||||
"minimal",
|
||||
"pretty"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
281
zsh.d/prompts/pure/readme.md
Normal file
281
zsh.d/prompts/pure/readme.md
Normal file
@ -0,0 +1,281 @@
|
||||
# Pure
|
||||
|
||||
> Pretty, minimal and fast ZSH prompt
|
||||
|
||||
<img src="screenshot.png" width="864">
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<p>
|
||||
<p>
|
||||
<sup>
|
||||
<a href="https://github.com/sponsors/sindresorhus">Sindre's open source work is supported by the community</a>
|
||||
</sup>
|
||||
</p>
|
||||
<sup>Special thanks to:</sup>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://github.com/botpress/botpress">
|
||||
<img src="https://sindresorhus.com/assets/thanks/botpress-logo.svg" width="260" alt="Botpress">
|
||||
</a>
|
||||
<br>
|
||||
<sub><b>Botpress is an open-source conversational assistant creation platform.</b></sub>
|
||||
<br>
|
||||
<sub>They <a href="https://github.com/botpress/botpress/blob/master/.github/CONTRIBUTING.md">welcome contributions</a> from anyone, whether you're into machine learning,<br>want to get started in open-source, or just have an improvement idea.</sub>
|
||||
<br>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
|
||||
## Overview
|
||||
|
||||
Most prompts are cluttered, ugly and slow. I wanted something visually pleasing that stayed out of my way.
|
||||
|
||||
### Why?
|
||||
|
||||
- Comes with the perfect prompt character.
|
||||
Author went through the whole Unicode range to find it.
|
||||
- Shows `git` branch and whether it's dirty (with a `*`).
|
||||
- Indicates when you have unpushed/unpulled `git` commits with up/down arrows. *(Check is done asynchronously!)*
|
||||
- Prompt character turns red if the last command didn't exit with `0`.
|
||||
- Command execution time will be displayed if it exceeds the set threshold.
|
||||
- Username and host only displayed when in an SSH session.
|
||||
- Shows the current path in the title and the [current folder & command](screenshot-title-cmd.png) when a process is running.
|
||||
- Support VI-mode indication by reverse prompt symbol (Zsh 5.3+).
|
||||
- Makes an excellent starting point for your own custom prompt.
|
||||
|
||||
## Install
|
||||
|
||||
Can be installed with `npm` or manually. Requires Git 2.0.0+ and ZSH 5.2+. Older versions of ZSH are known to work, but they are **not** recommended.
|
||||
|
||||
### npm
|
||||
|
||||
```console
|
||||
$ npm install --global pure-prompt
|
||||
```
|
||||
|
||||
That's it. Skip to [Getting started](#getting-started).
|
||||
|
||||
### Manually
|
||||
|
||||
1. Clone this repo somewhere. Here we'll use `$HOME/.zsh/pure`.
|
||||
|
||||
```sh
|
||||
mkdir -p "$HOME/.zsh"
|
||||
git clone https://github.com/sindresorhus/pure.git "$HOME/.zsh/pure"
|
||||
```
|
||||
|
||||
2. Add the path of the cloned repo to `$fpath` in `$HOME/.zshrc`.
|
||||
```sh
|
||||
# .zshrc
|
||||
fpath+=$HOME/.zsh/pure
|
||||
```
|
||||
|
||||
## Getting started
|
||||
|
||||
Initialize the prompt system (if not so already) and choose `pure`:
|
||||
|
||||
```sh
|
||||
# .zshrc
|
||||
autoload -U promptinit; promptinit
|
||||
prompt pure
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
| Option | Description | Default value |
|
||||
| :------------------------------- | :--------------------------------------------------------------------------------------------- | :------------- |
|
||||
| **`PURE_CMD_MAX_EXEC_TIME`** | The max execution time of a process before its run time is shown when it exits. | `5` seconds |
|
||||
| **`PURE_GIT_PULL=0`** | Prevents Pure from checking whether the current Git remote has been updated. | |
|
||||
| **`PURE_GIT_UNTRACKED_DIRTY=0`** | Do not include untracked files in dirtiness check. Mostly useful on large repos (like WebKit). | |
|
||||
| **`PURE_GIT_DELAY_DIRTY_CHECK`** | Time in seconds to delay git dirty checking when `git status` takes > 5 seconds. | `1800` seconds |
|
||||
| **`PURE_PROMPT_SYMBOL`** | Defines the prompt symbol. | `❯` |
|
||||
| **`PURE_PROMPT_VICMD_SYMBOL`** | Defines the prompt symbol used when the `vicmd` keymap is active (VI-mode). | `❮` |
|
||||
| **`PURE_GIT_DOWN_ARROW`** | Defines the git down arrow symbol. | `⇣` |
|
||||
| **`PURE_GIT_UP_ARROW`** | Defines the git up arrow symbol. | `⇡` |
|
||||
| **`PURE_GIT_STASH_SYMBOL`** | Defines the git stash symbol. | `≡` |
|
||||
|
||||
Showing git stash status as part of the prompt is not activated by default. To activate this you'll need to opt in via `zstyle`:
|
||||
|
||||
`zstyle :prompt:pure:git:stash show yes`
|
||||
|
||||
## Colors
|
||||
|
||||
As explained in ZSH's [manual](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting), color values can be:
|
||||
- A decimal integer corresponding to the color index of your terminal. If your `$TERM` is `xterm-256color`, see this [chart](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg).
|
||||
- The name of one of the following nine colors: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, and `default` (the terminal’s default foreground)
|
||||
- `#` followed by an RGB triplet in hexadecimal format, for example `#424242`. Only if your terminal supports 24-bit colors (true color) or when the [`zsh/nearcolor` module](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fnearcolor-Module) is loaded.
|
||||
|
||||
Colors can be changed by using [`zstyle`](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fzutil-Module) with a pattern of the form `:prompt:pure:$color_name` and style `color`. The color names, their default, and what part they affect are:
|
||||
- `execution_time` (yellow) - The execution time of the last command when exceeding `PURE_CMD_MAX_EXEC_TIME`.
|
||||
- `git:arrow` (cyan) - For `PURE_GIT_UP_ARROW` and `PURE_GIT_DOWN_ARROW`.
|
||||
- `git:stash` (cyan) - For `PURE_GIT_STASH_SYMBOL`.
|
||||
- `git:branch` (242) - The name of the current branch when in a Git repository.
|
||||
- `git:branch:cached` (red) - The name of the current branch when the data isn't fresh.
|
||||
- `git:action` (242) - The current action in progress (cherry-pick, rebase, etc.) when in a Git repository.
|
||||
- `git:dirty` (218) - The asterisk showing the branch is dirty.
|
||||
- `host` (242) - The hostname when on a remote machine.
|
||||
- `path` (blue) - The current path, for example, `PWD`.
|
||||
- `prompt:error` (red) - The `PURE_PROMPT_SYMBOL` when the previous command has *failed*.
|
||||
- `prompt:success` (magenta) - The `PURE_PROMPT_SYMBOL` when the previous command has *succeded*.
|
||||
- `prompt:continuation` (242) - The color for showing the state of the parser in the continuation prompt (PS2). It's the pink part in [this screenshot](https://user-images.githubusercontent.com/147409/70068574-ebc74800-15f8-11ea-84c0-8b94a4b57ff4.png), it appears in the same spot as `virtualenv`. You could for example matching both colors so that Pure has a uniform look.
|
||||
- `user` (242) - The username when on remote machine.
|
||||
- `user:root` (default) - The username when the user is root.
|
||||
- `virtualenv` (242) - The name of the Python `virtualenv` when in use.
|
||||
|
||||
The following diagram shows where each color is applied on the prompt:
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────────────────── user
|
||||
│ ┌─────────────────────────────────────────────── host
|
||||
│ │ ┌─────────────────────────────────── path
|
||||
│ │ │ ┌──────────────────────── git:branch
|
||||
│ │ │ │ ┌────────────────── git:dirty
|
||||
│ │ │ │ │ ┌──────────────── git:action
|
||||
│ │ │ │ │ │ ┌─────── git:arrow
|
||||
│ │ │ │ │ │ │ ┌───── git:stash
|
||||
│ │ │ │ │ │ │ │ ┌─── execution_time
|
||||
│ │ │ │ │ │ │ │ │
|
||||
zaphod@heartofgold ~/dev/pure master* rebase-i ⇡ ≡ 42s
|
||||
venv ❯
|
||||
│ │
|
||||
│ └───────────────────────────────────────────────── prompt
|
||||
└────────────────────────────────────────────────────── virtualenv (or prompt:continuation)
|
||||
```
|
||||
|
||||
### RGB colors
|
||||
|
||||
There are two ways to use RGB colors with the hexadecimal format. The correct way is to use a [terminal that support 24-bit colors](https://gist.github.com/XVilka/8346728) and enable this feature as explained in the terminal's documentation.
|
||||
|
||||
If you can't use such terminal, the module [`zsh/nearcolor`](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fnearcolor-Module) can be useful. It will map any hexadecimal color to the nearest color in the 88 or 256 color palettes of your termial, but without using the first 16 colors, since their values can be modified by the user. Keep in mind that when using this module you won't be able to display true RGB colors. It only allows you to specify colors in a more convenient way. The following is an example on how to use this module:
|
||||
|
||||
```sh
|
||||
# .zshrc
|
||||
zmodload zsh/nearcolor
|
||||
zstyle :prompt:pure:path color '#FF0000'
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```sh
|
||||
# .zshrc
|
||||
|
||||
autoload -U promptinit; promptinit
|
||||
|
||||
# optionally define some options
|
||||
PURE_CMD_MAX_EXEC_TIME=10
|
||||
|
||||
# change the path color
|
||||
zstyle :prompt:pure:path color white
|
||||
|
||||
# change the color for both `prompt:success` and `prompt:error`
|
||||
zstyle ':prompt:pure:prompt:*' color cyan
|
||||
|
||||
# turn on git stash status
|
||||
zstyle :prompt:pure:git:stash show yes
|
||||
|
||||
prompt pure
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
In the screenshot you see Pure running in [Hyper](https://hyper.is) with the [hyper-snazzy](https://github.com/sindresorhus/hyper-snazzy) theme and Menlo font.
|
||||
|
||||
The [Tomorrow Night Eighties](https://github.com/chriskempson/tomorrow-theme) theme with the [Droid Sans Mono](https://www.fontsquirrel.com/fonts/droid-sans-mono) font (15pt) is also a [nice combination](https://github.com/sindresorhus/pure/blob/95ee3e7618c6e2162a1e3cdac2a88a20ac3beb27/screenshot.png).<br>
|
||||
*Just make sure you have anti-aliasing enabled in your terminal.*
|
||||
|
||||
To have commands colorized as seen in the screenshot, install [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting).
|
||||
|
||||
## Integration
|
||||
|
||||
### [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
|
||||
|
||||
1. Set `ZSH_THEME=""` in your `.zshrc` to disable oh-my-zsh themes.
|
||||
2. Follow the Pure [Install](#install) instructions.
|
||||
3. Do not enable the following (incompatible) plugins: `vi-mode`, `virtualenv`.
|
||||
|
||||
**NOTE:** `oh-my-zsh` overrides the prompt so Pure must be activated *after* `source $ZSH/oh-my-zsh.sh`.
|
||||
|
||||
### [prezto](https://github.com/sorin-ionescu/prezto)
|
||||
|
||||
Pure is bundled with Prezto. No need to install it.
|
||||
|
||||
Add `prompt pure` to your `~/.zpreztorc`.
|
||||
|
||||
### [zim](https://github.com/Eriner/zim)
|
||||
|
||||
Add `zmodule sindresorhus/pure --source async.zsh --source pure.zsh` to your `.zimrc` and run `zimfw install`.
|
||||
|
||||
### [antigen](https://github.com/zsh-users/antigen)
|
||||
|
||||
Update your `.zshrc` file with the following two lines (order matters). Do not use the `antigen theme` function.
|
||||
|
||||
```sh
|
||||
antigen bundle mafredri/zsh-async
|
||||
antigen bundle sindresorhus/pure
|
||||
```
|
||||
|
||||
### [antibody](https://github.com/getantibody/antibody)
|
||||
|
||||
Update your `.zshrc` file with the following two lines (order matters):
|
||||
|
||||
```sh
|
||||
antibody bundle mafredri/zsh-async
|
||||
antibody bundle sindresorhus/pure
|
||||
```
|
||||
|
||||
### [zplug](https://github.com/zplug/zplug)
|
||||
|
||||
Update your `.zshrc` file with the following two lines:
|
||||
|
||||
```sh
|
||||
zplug mafredri/zsh-async, from:github
|
||||
zplug sindresorhus/pure, use:pure.zsh, from:github, as:theme
|
||||
```
|
||||
|
||||
### [zinit](https://github.com/zdharma/zinit)
|
||||
|
||||
Update your `.zshrc` file with the following two lines (order matters):
|
||||
|
||||
```sh
|
||||
zinit ice compile'(pure|async).zsh' pick'async.zsh' src'pure.zsh'
|
||||
zinit light sindresorhus/pure
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
There are currently no FAQs.
|
||||
|
||||
See [FAQ Archive](https://github.com/sindresorhus/pure/wiki/FAQ-Archive) for previous FAQs.
|
||||
|
||||
## Ports
|
||||
|
||||
- **ZSH**
|
||||
- [therealklanni/purity](https://github.com/therealklanni/purity) - More compact current working directory, important details on the main prompt line, and extra Git indicators.
|
||||
- [intelfx/pure](https://github.com/intelfx/pure) - Solarized-friendly colors, highly verbose, and fully async Git integration.
|
||||
- [dfurnes/purer](https://github.com/dfurnes/purer) - Compact single-line prompt with built-in Vim-mode indicator.
|
||||
- [chabou/pure-now](https://github.com/chabou/pure-now) - Fork with [Now](https://zeit.co/now) support.
|
||||
- [pure10k](https://gist.github.com/romkatv/7cbab80dcbc639003066bb68b9ae0bbf) - Configuration file for [Powerlevel10k](https://github.com/romkatv/powerlevel10k/) that makes it look like Pure.
|
||||
- **Bash**
|
||||
- [sapegin/dotfiles](https://github.com/sapegin/dotfiles) - [Prompt](https://github.com/sapegin/dotfiles/blob/dd063f9c30de7d2234e8accdb5272a5cc0a3388b/includes/bash_prompt.bash) and [color theme](https://github.com/sapegin/dotfiles/tree/master/color) for Terminal.app.
|
||||
- **Fish**
|
||||
- [brandonweiss/pure.fish](https://github.com/brandonweiss/pure.fish) - Pure-inspired prompt for Fish. Not intended to have feature parity.
|
||||
- [rafaelrinaldi/pure](https://github.com/rafaelrinaldi/pure) - Support for bare Fish and various framework ([Oh-My-Fish](https://github.com//oh-my-fish/oh-my-fish), [Fisherman](https://github.com//fisherman/fisherman), and [Wahoo](https://github.com//bucaran/wahoo)).
|
||||
- **Rust**
|
||||
- [xcambar/purs](https://github.com/xcambar/purs) - Pure-inspired prompt in Rust.
|
||||
- **Go**
|
||||
- [talal/mimir](https://github.com/talal/mimir) - Pure-inspired prompt in Go with Kubernetes and OpenStack cloud support. Not intended to have feature parity.
|
||||
- **PowerShell**
|
||||
- [nickcox/pure-pwsh](https://github.com/nickcox/pure-pwsh/) - PowerShell/PS Core implementation of the Pure prompt.
|
||||
|
||||
## Team
|
||||
|
||||
[](https://sindresorhus.com) | [](https://github.com/mafredri)
|
||||
---|---
|
||||
[Sindre Sorhus](https://github.com/sindresorhus) | [Mathias Fredriksson](https://github.com/mafredri)
|
BIN
zsh.d/prompts/pure/screenshot-title-cmd.png
Normal file
BIN
zsh.d/prompts/pure/screenshot-title-cmd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
zsh.d/prompts/pure/screenshot.png
Normal file
BIN
zsh.d/prompts/pure/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
Reference in New Issue
Block a user