From fa2eb6663f1639c4462621021618cb0ecbcafea0 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 25 Apr 2014 13:18:15 -0700 Subject: [PATCH] Move stuff from spectrum.sh into prompt.sh --- dotfiles/lib/zsh/prompt.sh | 35 +++++++++++++++++++++++++++++++---- dotfiles/lib/zsh/spectrum.sh | 28 ---------------------------- 2 files changed, 31 insertions(+), 32 deletions(-) delete mode 100644 dotfiles/lib/zsh/spectrum.sh diff --git a/dotfiles/lib/zsh/prompt.sh b/dotfiles/lib/zsh/prompt.sh index 868ad8b5..bf04d6ec 100644 --- a/dotfiles/lib/zsh/prompt.sh +++ b/dotfiles/lib/zsh/prompt.sh @@ -1,4 +1,31 @@ +##### COLOR SETUP autoload -U colors && colors +# P.C. Shyamshankar +# Copied from +# http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ +typeset -Ag FX FG BG +FX=( + reset "%{%}" + bold "%{%}" no-bold "%{%}" + italic "%{%}" no-italic "%{%}" + underline "%{%}" no-underline "%{%}" + blink "%{%}" no-blink "%{%}" + reverse "%{%}" no-reverse "%{%}" +) + +for color in {000..255}; do + FG[$color]="%{[38;5;${color}m%}" + BG[$color]="%{[48;5;${color}m%}" +done + +# Show all 256 colors with color number +function spectrum_ls() { + for code in {000..255}; do + print -P -- "$code: %{$FG[$code]Test%f%}" + done +} +##### + function current_directory() { local PWD=$(pwd) echo "${PWD/#$HOME/~}" @@ -29,21 +56,21 @@ function sandbox_prompt() { fi } -function prompt_use_custom_colors() { +function prompt_custom_colors() { export USERNAME_COLOR="$FG[040]" export SEPARATOR_COLOR="$FG[239]" export HOSTNAME_COLOR="$FG[033]" export CURRENT_DIRECTORY_COLOR="$FG[226]" } -function prompt_use_basic_colors() { +function prompt_basic_colors() { export USERNAME_COLOR="$fg[blue]" export SEPARATOR_COLOR="$fg[black]" export HOSTNAME_COLOR="$fg[green]" export CURRENT_DIRECTORY_COLOR="$fg[yellow]" } -function prompt_grey_separator() { +function prompt_basic_colors_with_grey_separator() { export USERNAME_COLOR="$fg[blue]" export SEPARATOR_COLOR="$FG[239]" export HOSTNAME_COLOR="$fg[green]" @@ -58,7 +85,7 @@ function separator() { print_with_color "$1" "$SEPARATOR_COLOR" } -prompt_use_custom_colors +prompt_basic_colors_with_grey_separator PROMPT='╭─% $(print_with_color "%n" "$USERNAME_COLOR") $(separator "at") $(print_with_color "`hostname -s`" "$HOSTNAME_COLOR") $(separator "in") $(print_with_color "`current_directory`" "$terminfo[bold]$CURRENT_DIRECTORY_COLOR")$(git_prompt_info)$(sandbox_prompt) ╰─± ' diff --git a/dotfiles/lib/zsh/spectrum.sh b/dotfiles/lib/zsh/spectrum.sh deleted file mode 100644 index 102c0430..00000000 --- a/dotfiles/lib/zsh/spectrum.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/zsh -# A script to make using 256 colors in zsh less painful. -# P.C. Shyamshankar -# Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ - -typeset -Ag FX FG BG - -FX=( - reset "%{%}" - bold "%{%}" no-bold "%{%}" - italic "%{%}" no-italic "%{%}" - underline "%{%}" no-underline "%{%}" - blink "%{%}" no-blink "%{%}" - reverse "%{%}" no-reverse "%{%}" -) - -for color in {000..255}; do - FG[$color]="%{[38;5;${color}m%}" - BG[$color]="%{[48;5;${color}m%}" -done - -# Show all 256 colors with color number -function spectrum_ls() { - for code in {000..255}; do - print -P -- "$code: %{$FG[$code]Test%f%}" - done -} -