diff options
author | Alan Pearce | 2014-02-04 17:25:15 +0000 |
---|---|---|
committer | Alan Pearce | 2014-02-04 17:25:15 +0000 |
commit | e31d0dbcfe860fc71e1f8917ed67c893297ae930 (patch) | |
tree | a47e34165800e0e612e05d0f5c3a755deecc7056 | |
parent | 5a5b0c4a566792c0bd8f793c4a49a1f1467b1d96 (diff) | |
download | nixfiles-e31d0dbcfe860fc71e1f8917ed67c893297ae930.tar.lz nixfiles-e31d0dbcfe860fc71e1f8917ed67c893297ae930.tar.zst nixfiles-e31d0dbcfe860fc71e1f8917ed67c893297ae930.zip |
Update pure prompt
-rw-r--r-- | zsh/functions/pure/prompt_pure_setup | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/zsh/functions/pure/prompt_pure_setup b/zsh/functions/pure/prompt_pure_setup index dae1fbb6..5c635037 100644 --- a/zsh/functions/pure/prompt_pure_setup +++ b/zsh/functions/pure/prompt_pure_setup @@ -16,6 +16,21 @@ # %m => shortname host # %(?..) => prompt conditional - %(condition.true.false) + +# turns seconds into human readable time +# 165392 => 1d 21h 56m 32s +prompt_pure_human_time() { + local tmp=$1 + local days=$(( tmp / 60 / 60 / 24 )) + local hours=$(( tmp / 60 / 60 % 24 )) + local minutes=$(( tmp / 60 % 60 )) + local seconds=$(( tmp % 60 )) + (( $days > 0 )) && echo -n "${days}d " + (( $hours > 0 )) && echo -n "${hours}h " + (( $minutes > 0 )) && echo -n "${minutes}m " + echo "${seconds}s" +} + # fastest possible way to check if repo is dirty prompt_pure_git_dirty() { # check if we're in a git repo @@ -31,7 +46,7 @@ prompt_pure_cmd_exec_time() { local stop=$(date +%s) local start=${cmd_timestamp:-$stop} integer elapsed=$stop-$start - (($elapsed > ${PURE_CMD_MAX_EXEC_TIME:=5})) && echo ${elapsed}s + (($elapsed > ${PURE_CMD_MAX_EXEC_TIME:=5})) && prompt_pure_human_time $elapsed } prompt_pure_preexec() { @@ -59,7 +74,7 @@ prompt_pure_precmd() { print -P $prompt_pure_preprompt # check async if there is anything to pull - { + (( ${PURE_GIT_PULL:-1} )) && { # check if we're in a git repo command git rev-parse --is-inside-work-tree &>/dev/null && # check check if there is anything to pull @@ -77,6 +92,10 @@ prompt_pure_precmd() { prompt_pure_setup() { + # prevent percentage showing up + # if output doesn't end with a newline + export PROMPT_EOL_MARK='' + prompt_opts=(cr subst percent) autoload -Uz add-zsh-hook @@ -93,7 +112,7 @@ prompt_pure_setup() { [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username='%n@%m ' # prompt turns red if the previous command didn't exit with 0 - PROMPT='%(?.%F{cyan}.%F{red})❯%f ' + PROMPT='%(?.%F{magenta}.%F{red})❯%f ' } prompt_pure_setup "$@" |