aboutsummaryrefslogtreecommitdiff
path: root/00-prompt.zsh
diff options
context:
space:
mode:
Diffstat (limited to '00-prompt.zsh')
-rw-r--r--00-prompt.zsh48
1 files changed, 48 insertions, 0 deletions
diff --git a/00-prompt.zsh b/00-prompt.zsh
index 21f6c95..b27691f 100644
--- a/00-prompt.zsh
+++ b/00-prompt.zsh
@@ -1,5 +1,53 @@
hostname=$( which hostname &>/dev/null && hostname || cat /etc/hostname )
+# Creates simple prompts for my many machines. #
+# The first argument to the prompts is the primary color
+# second argument is secondary color.
+
+GREEN="%{\x1b[01;32m%}"
+RED="%{\x1b[01;31m%}"
+RESET="%{\x1b[00m%}"
+
+function distro_logo {
+ case "$(uname -a)" in
+ *-arch*) echo "%{\033[01;38;2;21;118;167m%}$RESET" ;;
+ *Debian*) echo "%{\033[01;38;2;170;6;64m%}$RESET" ;;
+ *Ubuntu*) echo "%{\033[01;38;2;172;61;24m%}$RESET" ;;
+ *fc*) echo "%{\033[01;38;2;21;118;167m%}$RESET" ;;
+ *gentoo*) echo "%{\033[01;38;2;126;126;183m%}$RESET" ;;
+ *Linux*) echo "%{\033[01;37m%}$RESET" ;;
+ *BSD*) echo "%{\033[01;31m%}$RESET" ;;
+ esac
+}
+
+function simple_prompt {
+ ec=$?
+ preamble=""
+
+ default="${2}"
+ if [ "$ec" -eq "0" ] ; then
+ code="${GREEN}--${default}"
+ else
+ code="${RED}$(printf '%02x' $ec)${default}"
+ fi
+
+ name="${1}%n@${default}"
+ host="${1}%m${default}"
+ directory="${2}%2~${default}"
+
+ echo " ${default}$(distro_logo) ${code} ${name}${host} ${directory} · %{\x1b[00m%}"
+}
+
+function simple_rprompt {
+ default="${2}"
+ time="${1}%*${default}"
+ echo "${default}← ${time} ${RESET}"
+}
+
+setopt prompt_subst
+
+# Source the actual prompt file corresponding to this host.
+
source "$HOME/.zshrc.d/prompts/${hostname}.zsh" 2>/dev/null || \
source "$HOME/.zshrc.d/local/prompts/${hostname}.zsh" 2>/dev/null