aboutsummaryrefslogtreecommitdiffstats
path: root/.zsh.prompts/prompt_kylewest_setup
blob: c67b5e49aa52173ce128cea9851d994f441106cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# A theme based on sorin theme
#  * ruby info shown on the right
#  * git info on the left
#  * editor mode as $> or <#
#  * single line prompt
#
# Authors:
#   Sorin Ionescu <sorin.ionescu@gmail.com>
#   Kyle West <kswest@gmail.com>

function prompt_kylewest_precmd {
  setopt LOCAL_OPTIONS
  unsetopt XTRACE KSH_ARRAYS

  # Get Git repository information.
  if (( $+functions[git-info] )); then
    git-info on
    git-info
  fi

  # Get ruby information
  if (( $+functions[ruby-info] )); then
    ruby-info
  fi
}

function prompt_kylewest_setup {
  setopt LOCAL_OPTIONS
  unsetopt XTRACE KSH_ARRAYS
  prompt_opts=(cr percent subst)

  # Load required functions.
  autoload -Uz add-zsh-hook

  # Add hook for calling git-info before each command.
  add-zsh-hook precmd prompt_kylewest_precmd

  # editor
  zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
  zstyle ':prezto:module:editor:info:keymap:primary' format "%B%F{green}$>%f%b"
  zstyle ':prezto:module:editor:info:keymap:alternate' format "%B%F{magenta}<#%f%b"

  # ruby info (rvm, rbenv)
  zstyle ':prezto:module:ruby:info:version' format '[ %v ]'

  # vcs
  zstyle ':prezto:module:git:info:branch' format '%F{yellow}%b%f'
  zstyle ':prezto:module:git:info:dirty' format '%B%F{red}!%f%b'
  zstyle ':prezto:module:git:info:keys' format 'prompt' '- %b%D '

  # prompts
  PROMPT='%F{cyan}%c%f ${git_info[prompt]}${editor_info[keymap]} '
  RPROMPT='%F{blue}${ruby_info[version]}'
}

prompt_kylewest_setup "$@"