Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Simple prompt theme



I've made a simple prompt theme that displays "user@host:path>" by default in white but can accept up to two colors. I use it with "cyan blue" but it looks good with "red yellow" too, maybe I shouldn't leave the default color white? Anyway, it basically shows what the "redhat" and "suse" prompts do but in a way that still allows people to set colors to brighten up their prompt. I'm not sure if I need this line, but the other themes seem to have it (now that's peer pressure!):
prompt_opts=( cr percent )

I hope it doesn't bother anyone if I paste it at the end of this email. I could do a diff -u with an empty file but that doesn't make much sense. I suppose it's a bit much of me to even think others might want to use it (but I'm proud of it), at least I didn't call it the dirus theme. ;) I hope this is the right mailing list for it (I didn't know if I should post to workers or to users), and I hope no one minds the extra 2k in their inbox.

prompt_simple_setup:
# Created by Dirus

prompt_simple_help () {
  cat <<'EOF'
As it's name suggests, this prompt is designed to be small and to work
with all fonts, and yet still provide useful information.

This prompt is color-scheme-able.  You can invoke it thus:
  prompt simple [<text-color> [<punctuation-color>]]

The default color is just white and is intended to work on a black
background.  Simply use darker colors (such as black) for use on a
lighter background.
EOF
}

prompt_simple_setup () {
  local text_color=${1:-'white'}
  local _text="%{$fg_no_bold[$text_color]%}"
  local _other="%{$fg_bold[${2:-$text_color}]%}"

  PS1="$_text%n$_other@$_text%m$_other:$_text%~$_other>%{$reset_color%} "
  PS2="$_other>%{$reset_color%} "

  prompt_opts=( cr percent )
  precmd () { }
  preexec () { }
}

prompt_simple_preview () {
  if (( ! $#* )); then
    prompt_preview_theme simple
    print
    prompt_preview_theme simple green
    print
    prompt_preview_theme simple red yellow
    print
    prompt_preview_theme simple white yellow
    print
    prompt_preview_theme simple cyan blue
    print
    prompt_preview_theme simple green blue
  else
    prompt_preview_theme simple "$@"
  fi
}

prompt_simple_setup "$@"



Messages sorted by: Reverse Date, Date, Thread, Author