forked from colonelpanic/dotfiles
		
	Move stuff from spectrum.sh into prompt.sh
This commit is contained in:
		| @@ -1,4 +1,31 @@ | |||||||
|  | ##### COLOR SETUP | ||||||
| autoload -U colors && colors | autoload -U colors && colors | ||||||
|  | # P.C. Shyamshankar <sykora@lucentbeing.com> | ||||||
|  | # Copied from | ||||||
|  | # http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ | ||||||
|  | typeset -Ag FX FG BG | ||||||
|  | FX=( | ||||||
|  |     reset     "%{[00m%}" | ||||||
|  |     bold      "%{[01m%}" no-bold      "%{[22m%}" | ||||||
|  |     italic    "%{[03m%}" no-italic    "%{[23m%}" | ||||||
|  |     underline "%{[04m%}" no-underline "%{[24m%}" | ||||||
|  |     blink     "%{[05m%}" no-blink     "%{[25m%}" | ||||||
|  |     reverse   "%{[07m%}" no-reverse   "%{[27m%}" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | 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() { | function current_directory() { | ||||||
|     local PWD=$(pwd) |     local PWD=$(pwd) | ||||||
|     echo "${PWD/#$HOME/~}" |     echo "${PWD/#$HOME/~}" | ||||||
| @@ -29,21 +56,21 @@ function sandbox_prompt() { | |||||||
|     fi |     fi | ||||||
| } | } | ||||||
|  |  | ||||||
| function prompt_use_custom_colors() { | function prompt_custom_colors() { | ||||||
|     export USERNAME_COLOR="$FG[040]" |     export USERNAME_COLOR="$FG[040]" | ||||||
|     export SEPARATOR_COLOR="$FG[239]" |     export SEPARATOR_COLOR="$FG[239]" | ||||||
|     export HOSTNAME_COLOR="$FG[033]" |     export HOSTNAME_COLOR="$FG[033]" | ||||||
|     export CURRENT_DIRECTORY_COLOR="$FG[226]" |     export CURRENT_DIRECTORY_COLOR="$FG[226]" | ||||||
| } | } | ||||||
|  |  | ||||||
| function prompt_use_basic_colors() { | function prompt_basic_colors() { | ||||||
|     export USERNAME_COLOR="$fg[blue]" |     export USERNAME_COLOR="$fg[blue]" | ||||||
|     export SEPARATOR_COLOR="$fg[black]" |     export SEPARATOR_COLOR="$fg[black]" | ||||||
|     export HOSTNAME_COLOR="$fg[green]" |     export HOSTNAME_COLOR="$fg[green]" | ||||||
|     export CURRENT_DIRECTORY_COLOR="$fg[yellow]" |     export CURRENT_DIRECTORY_COLOR="$fg[yellow]" | ||||||
| } | } | ||||||
|  |  | ||||||
| function prompt_grey_separator() { | function prompt_basic_colors_with_grey_separator() { | ||||||
|     export USERNAME_COLOR="$fg[blue]" |     export USERNAME_COLOR="$fg[blue]" | ||||||
|     export SEPARATOR_COLOR="$FG[239]" |     export SEPARATOR_COLOR="$FG[239]" | ||||||
|     export HOSTNAME_COLOR="$fg[green]" |     export HOSTNAME_COLOR="$fg[green]" | ||||||
| @@ -58,7 +85,7 @@ function separator() { | |||||||
|     print_with_color "$1" "$SEPARATOR_COLOR" |     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) | 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) | ||||||
| ╰─± ' | ╰─± ' | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,28 +0,0 @@ | |||||||
| #!/bin/zsh |  | ||||||
| # A script to make using 256 colors in zsh less painful. |  | ||||||
| # P.C. Shyamshankar <sykora@lucentbeing.com> |  | ||||||
| # Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ |  | ||||||
|  |  | ||||||
| typeset -Ag FX FG BG |  | ||||||
|  |  | ||||||
| FX=( |  | ||||||
|     reset     "%{[00m%}" |  | ||||||
|     bold      "%{[01m%}" no-bold      "%{[22m%}" |  | ||||||
|     italic    "%{[03m%}" no-italic    "%{[23m%}" |  | ||||||
|     underline "%{[04m%}" no-underline "%{[24m%}" |  | ||||||
|     blink     "%{[05m%}" no-blink     "%{[25m%}" |  | ||||||
|     reverse   "%{[07m%}" no-reverse   "%{[27m%}" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| 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 |  | ||||||
| } |  | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user