From e3d28aba4f448ab5042bf898c6a0a8e26296d764 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Thu, 6 Sep 2018 15:59:35 +0200 Subject: [PATCH] Implement my own theme. Theme mostly looks the same, but with slightly less fancy calculations about line widths. This is okay for now. --- zsh/.config/zsh/.zshrc | 4 +--- zsh/.config/zsh/.zshtheme | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 zsh/.config/zsh/.zshtheme diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 379c98c..15014c5 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -42,9 +42,7 @@ then fi # Initialize the prompt -autoload -U promptinit -promptinit -prompt bart +source "${ZDOTDIR:-$HOME}/.zshtheme" # Setup the CNF hook if [[ -s /usr/share/doc/pkgfile/command-not-found.zsh ]]; then diff --git a/zsh/.config/zsh/.zshtheme b/zsh/.config/zsh/.zshtheme new file mode 100644 index 0000000..7e8b324 --- /dev/null +++ b/zsh/.config/zsh/.zshtheme @@ -0,0 +1,44 @@ +# vim: setf zsh + +# Allow color escape sequences to be available +autoload -U colors && colors + +# Allow calling functions inside prompt +setopt PROMPT_SUBST + +function prompt_last_cmd() { + if [[ $HISTCMD -gt 0 ]]; then + echo $history[$((HISTCMD - 1))] + fi +} + +function prompt_ps1() { + local ps1 rs='%b%f%k' + local dir="%{$fg[%~]%}%8~$rs" + local hist="%{$fg[blue]%}[\$(prompt_last_cmd)]$rs " + local host="%{$fg[red]%}%m " + + local prompt="%n@%{$fg[cyan]%}%m$rs %(#.#.\$) " + ps1=( + "$host" + "$hist" + "$dir" + $'\n' + "$prompt" + ) + echo "${(j::)ps1}" +} + +function prompt_rprompt() { + local rprompt rs='%b%f%k' hist1 hist2 + local exit_status="%(?..%{$fg[red]%}- %{$fg_bold[yellow]%}%? %b%{$fg[red]%}-$rs )" + local datetime="%D %{$fg[red]%}%T%{$reset_color%}" + rprompt=( + "$exit_status" + "$datetime" + ) + echo "${(j::)rprompt}" +} + +PS1="$(prompt_ps1)" +RPROMPT="$(prompt_rprompt)"