Closure over the local variables by wrapping everything in a anonymous function
Also namespace all the functions as they will always be global
This commit is contained in:
9
pure.zsh
9
pure.zsh
@@ -17,6 +17,8 @@
|
||||
# %m => shortname host
|
||||
# %(?..) => prompt conditional - %(condition.true.false)
|
||||
|
||||
|
||||
() {
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
@@ -34,7 +36,7 @@ setopt PROMPT_SUBST
|
||||
[ $USER != "$PURE_DEFAULT_USERNAME" ] && local username='%n@%m '
|
||||
|
||||
# fastest possible way to check if repo is dirty
|
||||
git_dirty() {
|
||||
pure_git_dirty() {
|
||||
# check if we're in a git repo
|
||||
command git rev-parse --is-inside-work-tree &>/dev/null || return
|
||||
# check if it's dirty
|
||||
@@ -42,7 +44,7 @@ git_dirty() {
|
||||
}
|
||||
|
||||
# displays the exec time of the last command if set threshold was exceeded
|
||||
cmd_exec_time() {
|
||||
pure_cmd_exec_time() {
|
||||
local stop=`date +%s`
|
||||
local start=${cmd_timestamp:-$stop}
|
||||
let local elapsed=$stop-$start
|
||||
@@ -56,7 +58,7 @@ pure_preexec() {
|
||||
pure_precmd() {
|
||||
vcs_info
|
||||
# add `%*` to display the time
|
||||
print -P '\n%F{blue}%~%F{8}$vcs_info_msg_0_`git_dirty` $username%f %F{yellow}`cmd_exec_time`%f'
|
||||
print -P '\n%F{blue}%~%F{8}$vcs_info_msg_0_`pure_git_dirty` $username%f %F{yellow}`pure_cmd_exec_time`%f'
|
||||
# reset value since `preexec` isn't always triggered
|
||||
unset cmd_timestamp
|
||||
}
|
||||
@@ -65,3 +67,4 @@ pure_precmd() {
|
||||
PROMPT='%(?.%F{magenta}.%F{red})❯%f '
|
||||
# can be disabled:
|
||||
# PROMPT='%F{magenta}❯%f '
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user