summaryrefslogtreecommitdiffstats
path: root/.zsh
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-01-06 16:02:15 +0100
committerGravatar Tom Willemsen2012-01-06 16:02:15 +0100
commit63bbc2e2ea8c0a5a26571b95f6b61e6f6a39b0ab (patch)
tree3625b9f302aff206e6f68fd94283c30e6457f989 /.zsh
parent21eb3b9ec8b9a22b9abda2044ff71177f88835e5 (diff)
downloaddotfiles-63bbc2e2ea8c0a5a26571b95f6b61e6f6a39b0ab.tar.gz
dotfiles-63bbc2e2ea8c0a5a26571b95f6b61e6f6a39b0ab.zip
ZSH: Change prompt again
Change the prompt and divide into extra files.
Diffstat (limited to '.zsh')
-rw-r--r--.zsh/functions/get_cnt15
-rw-r--r--.zsh/functions/precmd_update_updates11
-rwxr-xr-x.zsh/functions/preexec_update_git_vars6
-rw-r--r--.zsh/functions/preexec_update_vars12
-rw-r--r--.zsh/functions/prompt16
-rw-r--r--.zsh/functions/rprompt4
6 files changed, 58 insertions, 6 deletions
diff --git a/.zsh/functions/get_cnt b/.zsh/functions/get_cnt
new file mode 100644
index 0000000..5b06e00
--- /dev/null
+++ b/.zsh/functions/get_cnt
@@ -0,0 +1,15 @@
+# -*- mode: shell-script -*-
+
+if [ -n "$1" ]; then
+ if [ -e "~/.local/share/$1.cnt" ]; then
+ cnt=$(/bin/cat "~/.local/share/$1.cnt")
+ fi
+
+ if [ -z "$cnt" ]; then
+ cnt=0
+ fi
+
+ echo $cnt
+else
+ echo "No count name specified" >&2
+fi
diff --git a/.zsh/functions/precmd_update_updates b/.zsh/functions/precmd_update_updates
new file mode 100644
index 0000000..639fd5c
--- /dev/null
+++ b/.zsh/functions/precmd_update_updates
@@ -0,0 +1,11 @@
+# -*- mode: shell-script -*-
+
+if [ -n "$__EXECUTED_PACMAN_COMMAND" ]; then
+ update_pac_cnt
+ unset __EXECUTED_PACMAN_COMMAND
+fi
+
+if [ -n "$__EXECUTED_COWER_COMMAND" ]; then
+ update_aur_cnt
+ unset __EXECUTED_COWER_COMMAND
+fi
diff --git a/.zsh/functions/preexec_update_git_vars b/.zsh/functions/preexec_update_git_vars
deleted file mode 100755
index 9d229a9..0000000
--- a/.zsh/functions/preexec_update_git_vars
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- mode: shell-script -*-
-case "$1" in
- git*)
- __EXECUTED_GIT_COMMAND=1
- ;;
-esac
diff --git a/.zsh/functions/preexec_update_vars b/.zsh/functions/preexec_update_vars
new file mode 100644
index 0000000..70f3d68
--- /dev/null
+++ b/.zsh/functions/preexec_update_vars
@@ -0,0 +1,12 @@
+# -*- mode: shell-script -*-
+case "$1" in
+ git*)
+ __EXECUTED_GIT_COMMAND=1
+ ;;
+ cower)
+ __EXECUTED_COWER_COMMAND=1
+ ;;
+ pacman)
+ __EXECUTED_PACMAN_COMMAND=1
+ ;;
+esac
diff --git a/.zsh/functions/prompt b/.zsh/functions/prompt
new file mode 100644
index 0000000..af15976
--- /dev/null
+++ b/.zsh/functions/prompt
@@ -0,0 +1,16 @@
+# -*- mode: shell-script -*-
+
+local pac_cnt=$(get_cnt updates)
+local aur_cnt=$(get_cnt aur)
+local hostname=$(hostname | cut -d . -f 1)
+
+if [ $pac_cnt -gt 0 -o $aur_cnt -gt 0 ]; then
+ printf "%s%d%s/%s%d%s:" \
+ "%{${fg[cyan]}%}" $pac_cnt "%{${fg[default]}%}" \
+ "%{${fg[cyan]}%}" $aur_cnt "%{${fg[default]}%}"
+fi
+
+printf '%s%s%s:%s%s%s%s>%s ' \
+ "%{${fg[magenta]}%}" $hostname "%{${fg[default]}%}" \
+ "%{${fg[green]}%}" "%~" "%{${fg[default]}%}" \
+ "%(?.%{${fg[green]}%}.%{${fg[red]}%})%B" "%b%{${fg[default]}%}"
diff --git a/.zsh/functions/rprompt b/.zsh/functions/rprompt
new file mode 100644
index 0000000..3392379
--- /dev/null
+++ b/.zsh/functions/rprompt
@@ -0,0 +1,4 @@
+# -*- mode: shell-script -*-
+
+local git_info="$(prompt_git_info)"
+printf '%s%s' $git_info "%{${fg[default]}%}"