diff options
-rw-r--r-- | 00-prompt.zsh | 48 | ||||
-rw-r--r-- | prompts/lepton.zsh | 2 |
2 files changed, 50 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 diff --git a/prompts/lepton.zsh b/prompts/lepton.zsh new file mode 100644 index 0000000..d85541c --- /dev/null +++ b/prompts/lepton.zsh @@ -0,0 +1,2 @@ +PROMPT='$(simple_prompt "%{\x1b[01;36m%}" "%{\x1b[01;38;05;243m%}")' +RPROMPT='$(simple_rprompt "%{\x1b[01;36m%}" "%{\x1b[01;38;05;243m%}")' |