aboutsummaryrefslogtreecommitdiff
path: root/00-prompt.zsh
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2021-11-15 10:22:57 -0700
committerJosh Rahm <rahm@google.com>2021-11-15 10:22:57 -0700
commiteef56cd6f76244cb7ab54a45ac1c60aa3e658f12 (patch)
treeda365c307a74922598df1a610e1d9a767f5afbe9 /00-prompt.zsh
parent509b3462c5957b705ef02d8364b50e8c25c9d0dd (diff)
parent8492e58a8886c848b9dd6310dc6d2f4345a4a0c5 (diff)
downloadzshrcd-eef56cd6f76244cb7ab54a45ac1c60aa3e658f12.tar.gz
zshrcd-eef56cd6f76244cb7ab54a45ac1c60aa3e658f12.tar.bz2
zshrcd-eef56cd6f76244cb7ab54a45ac1c60aa3e658f12.zip
Merge branch 'main' of git.josher.dev:zshrcd
Diffstat (limited to '00-prompt.zsh')
-rw-r--r--00-prompt.zsh56
1 files changed, 54 insertions, 2 deletions
diff --git a/00-prompt.zsh b/00-prompt.zsh
index 439a25d..b27691f 100644
--- a/00-prompt.zsh
+++ b/00-prompt.zsh
@@ -1,2 +1,54 @@
-source "$HOME/.zshrc.d/prompts/$(hostname).zsh" 2>/dev/null || \
- source "$HOME/.zshrc.d/local/prompts/$(hostname).zsh" 2>/dev/null
+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
+
+PROMPT='[5 q'"$PROMPT"