summary refs log tree commit diff stats
path: root/zsh/functions/pure/prompt_pure_setup
diff options
context:
space:
mode:
Diffstat (limited to 'zsh/functions/pure/prompt_pure_setup')
-rw-r--r--zsh/functions/pure/prompt_pure_setup25
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 "$@"