Move the options out of the prompt
So users don't have to modify the prompt to be able to change the options.
This commit is contained in:
12
pure.zsh
12
pure.zsh
@@ -4,13 +4,6 @@
|
|||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
|
|
||||||
# change this to your own username
|
|
||||||
DEFAULT_USERNAME='sindresorhus'
|
|
||||||
|
|
||||||
# threshold (sec) for showing cmd exec time
|
|
||||||
CMD_MAX_EXEC_TIME=5
|
|
||||||
|
|
||||||
|
|
||||||
# For my own and others sanity
|
# For my own and others sanity
|
||||||
# git:
|
# git:
|
||||||
# %b => current branch
|
# %b => current branch
|
||||||
@@ -33,8 +26,7 @@ zstyle ':vcs_info:git*' actionformats ' %b|%a'
|
|||||||
setopt PROMPT_SUBST
|
setopt PROMPT_SUBST
|
||||||
|
|
||||||
# only show username if not default
|
# only show username if not default
|
||||||
[ $USER != $DEFAULT_USERNAME ] && local username='%n@%m '
|
[ $USER != "$PURE_DEFAULT_USERNAME" ] && local username='%n@%m '
|
||||||
|
|
||||||
|
|
||||||
# fastest possible way to check if repo is dirty
|
# fastest possible way to check if repo is dirty
|
||||||
git_dirty() {
|
git_dirty() {
|
||||||
@@ -49,7 +41,7 @@ cmd_exec_time() {
|
|||||||
local stop=`date +%s`
|
local stop=`date +%s`
|
||||||
local start=${cmd_timestamp:-$stop}
|
local start=${cmd_timestamp:-$stop}
|
||||||
let local elapsed=$stop-$start
|
let local elapsed=$stop-$start
|
||||||
[ $elapsed -gt $CMD_MAX_EXEC_TIME ] && echo ${elapsed}s
|
[ $elapsed -gt "${PURE_CMD_MAX_EXEC_TIME:=5}" ] && echo ${elapsed}s
|
||||||
}
|
}
|
||||||
|
|
||||||
preexec() {
|
preexec() {
|
||||||
|
|||||||
18
readme.md
18
readme.md
@@ -19,11 +19,21 @@ Most prompts are cluttered, ugly and slow. I wanted something visually pleasing
|
|||||||
- Can easily be used as a starting point for your own custom prompt
|
- Can easily be used as a starting point for your own custom prompt
|
||||||
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting started
|
||||||
|
|
||||||
- Download `pure.zsh` or submodule this repo
|
- Download `pure.zsh` or submodule this repo.
|
||||||
- In your `.zshrc` add `. path/to/pure.zsh`
|
- In your `.zshrc` add any of the below options, then import pure `. path/to/pure.zsh`.
|
||||||
- Add your username to `DEFAULT_USERNAME`
|
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
### `PURE_DEFAULT_USERNAME`
|
||||||
|
|
||||||
|
Define your username if you want to hide it from the prompt when it matches the current username.
|
||||||
|
|
||||||
|
### `PURE_CMD_MAX_EXEC_TIME`
|
||||||
|
|
||||||
|
The max execution time of a process before its run time is shown when it exits. Defaults to `5` seconds.
|
||||||
|
|
||||||
|
|
||||||
## Tip
|
## Tip
|
||||||
|
|||||||
Reference in New Issue
Block a user