async-pure
v1.7.0
Published
Pretty, minimal and fast ZSH prompt based on Pure
Downloads
8
Maintainers
Readme
Async Pure
Pretty, minimal and fast ZSH prompt based on Pure
This is a fork of sindresorhus/pure, which aims towards:
- fully async git integration
- Monokai friendly colors --- for machines and people!
Overview
Most prompts smash way too much together into an unreadable heap which creates a cluttered, ugly, and ridiculously slow environment. I wanted something visually pleasing that stayed out of my way while still providing the functionality that I need.
Variations
- Comes with
λ
as the prompt character because I like lambdas. Changed with PURE_PROMPT_SYMBOL variable. - Shows
git
branch, whether it has modified/staged/untracked files and upstream status with up/down triangles. All checks are asynchronous. - Prompt character turns red if the last command didn't exit with
0
. - Command execution time displays if it exceeds the set threshold.
- Username and host colored depending on UID and presence of the SSH session.
- Shows the current path in the title and the current command when a process is running.
- Makes a perfect starting point for your own custom prompt.
Install
Requires Git 2.0.0+ and ZSH 5.2+. Older versions of ZSH work, but they are not recommended.
I don't care. Install it with whatever tools you want. No hipster-style
npm --global
installation or other bullshit included.Symlink
async_pure.zsh
to somewhere in$fpath
with the nameprompt_pure_setup
.Symlink
async.zsh
in$fpath
with the nameasync
.
npm
$ npm install --global async-pure
or
$ yarn global add async-pure
That's it. Skip to Getting started.
Manually
$ ln -s "$PWD/async_pure.zsh" /usr/local/share/zsh/site-functions/prompt_pure_setup
$ ln -s "$PWD/async.zsh" /usr/local/share/zsh/site-functions/async
Run echo $fpath
to see possible locations.
For a user-specific installation (which would not require escalated privileges), simply add a directory to $fpath
for that user:
# .zshenv or .zshrc
fpath=( "$HOME/.zfunctions" $fpath )
Then install the theme there:
$ ln -s "$PWD/async_pure.zsh" "$HOME/.zfunctions/prompt_pure_setup"
$ ln -s "$PWD/async.zsh" "$HOME/.zfunctions/async"
Getting started
Initialize the prompt system (if not so already) and choose pure
:
# .zshrc
autoload -U promptinit; promptinit
prompt pure
Options
| Option | Explanation | Default |
| ------------------------------- | --------------------------------------------------------------- | ------------ |
| PURE_CMD_MAX_EXEC_TIME
| max execution time of a process before it is shown | 5
seconds |
| PURE_GIT_FETCH
| automatic git fetch
, done only once per repo | 1
|
| PURE_GIT_FETCH_RETRY
| timeout between git fetch
retries if failed | 10
seconds |
| PURE_GIT_UNTRACKED
| enables untracked files in worktree check (disable for speedup) | 1
|
| PURE_GIT_DELAY_WORKTREE_CHECK
| timeout between git worktree checks, when they take > 2 seconds | 60
|
| PURE_GIT_DELAY_UPSTREAM_CHECK
| timeout between git upstream checks, when they take > 2 seconds | 60
|
| PURE_PROMPT_SYMBOL
| the command prompt symbol | λ
|
| PURE_GIT_DOWN_ARROW
| git info symbol: branch behind its upstream | ▼
|
| PURE_GIT_UP_ARROW
| git info symbol: branch ahead of its upstream | ▲
|
| PURE_GIT_DIRTY
| git info symbol: branch has uncommited changes | x
|
| PURE_GIT_EVEN_ARROW
| git info symbol: branch is even with its upstream | empty string |
| PURE_GIT_FETCH_IN_PROGRESS
| git info string: async fetch in progress | (fetch...)
|
| PURE_GIT_FETCH_FAILED
| git info string: async fetch failed, will retry | (fetch!)
|
| PURE_GIT_UPSTREAM_NA
| git info string: async upstream check in progress | ?u
|
| PURE_GIT_WORKTREE_NA
| git info string: async worktree check in progress | ?w
|
| PURE_DEBUG
| debug output in systemd journal (journalctl -t zshpure
) | 0
|
| PURE_ALWAYS_SHOW_USER
| show user@host
always, not only when connected through SSH | 0
|
The worktree/upstream checks throttle when the last check takes > 2 seconds. This is to save CPU time.
Custom handlers
There is a global array prompt_pure_pieces
comprised of functions generating
pieces of the preprompt. To add a custom entry to the preprompt, declare a function
generating custom text and insert its name as an entry into the prompt_pure_pieces
array.
The custom function must return generated text by appending new entries to the
preprompt
array (declared in a parent scope) See below for an example.
Handler Example
# .zshrc
autoload -U promptinit; promptinit
# optionally define some options
PURE_CMD_MAX_EXEC_TIME=10
# optionally define custom generators
prompt_custom() {
preprompt+=( custom )
}
prompt pure
# add the generator where it's needed
prompt_pure_pieces=(
${prompt_pure_pieces:0:2}
prompt_custom
${prompt_pure_pieces:2}
)
Tips
In the screenshot you see Async Pure running in iTerm2 with the monokai-soda theme and Source Code Pro for Powerline font.
The Tomorrow Night Eighties theme with the Droid Sans Mono font (15pt) is also a nice combination. Just make sure you have anti-aliasing enabled in your terminal.
To have commands colorized as seen in the screenshot, install zsh-syntax-highlighting.
Integration
oh-my-zsh
- Set
ZSH_THEME=""
in your.zshrc
to disable oh-my-zsh themes. - Follow the Pure Install instructions.
NOTE: oh-my-zsh
overrides the prompt so Pure must be activated after source $ZSH/oh-my-zsh.sh
.
OR
Symlink async-pure.zsh to async-pure.zsh-theme.
ln -s "$PWD/async_pure.zsh" "$HOME/.oh-my-zsh/custom/themes/async-pure.zsh-theme"
Set ZSH_THEME="async-pure" in your .zshrc.
antigen
Update your .zshrc
file with the following two lines (order matters). Do not use the antigen theme
function.
antigen bundle mafredri/zsh-async
antigen bundle jschwrtz/async-pure
antibody
Update your .zshrc
file with the following two lines (order matters):
antibody bundle mafredri/zsh-async
antibody bundle jschwrtz/async-pure
zplug
Update your .zshrc
file with the following two lines:
zplug mafredri/zsh-async, from:github
zplug jschwrtz/async-pure, use:async_pure.zsh, from:github, as:theme
License
Original code: MIT© Sindre Sorhus
Further work: Copyright (c) 2017 Jay Schwartz
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.