Last active
August 29, 2015 14:13
-
-
Save kahirul/80eb5a0c22fec93d870c to your computer and use it in GitHub Desktop.
Custom Presto Prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # A simple theme that displays relevant, contextual information. | |
| # | |
| # Authors: | |
| # Sorin Ionescu <[email protected]> | |
| # | |
| # Screenshots: | |
| # http://i.imgur.com/nBEEZ.png | |
| # | |
| # Load dependencies. | |
| pmodload 'helper' | |
| function prompt_meow_pwd { | |
| local pwd="${PWD/#$HOME/~}" | |
| if [[ "$pwd" == (#m)[/~] ]]; then | |
| _prompt_meow_pwd="$MATCH" | |
| unset MATCH | |
| else | |
| _prompt_meow_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}" | |
| fi | |
| } | |
| function prompt_meow_precmd { | |
| setopt LOCAL_OPTIONS | |
| unsetopt XTRACE KSH_ARRAYS | |
| # Format PWD. | |
| prompt_meow_pwd | |
| # 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_meow_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_meow_precmd | |
| # Set editor-info parameters. | |
| zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b' | |
| zstyle ':prezto:module:editor:info:keymap:primary' format ' %B%F{red}❯%F{green}❯%f%b' | |
| zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format ' %F{red}♺%f' | |
| zstyle ':prezto:module:editor:info:keymap:alternate' format ' %B%F{green}❮%F{red}❮%f%b' | |
| # Set git-info parameters. | |
| zstyle ':prezto:module:git:info:branch' format '%F{yellow}%b%f' | |
| zstyle ':prezto:module:git:info:added' format ' %%B%F{green}●%f%%b' | |
| zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}●%f%%b' | |
| zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}●%f%%b' | |
| zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}●%f%%b' | |
| zstyle ':prezto:module:git:info:keys' format 'prompt' ' § %b%d%a%m%u' | |
| # ruby info (rvm, rbenv) | |
| zstyle ':prezto:module:ruby:info:version' format '§ %%B%F{red}%v%f%%b' | |
| # Define prompts. | |
| PROMPT='%F{cyan}${_prompt_meow_pwd}%f${(e)git_info[prompt]}%f | |
| § ' | |
| RPROMPT='${ruby_info[version]}%f' | |
| SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? ' | |
| } | |
| prompt_meow_setup "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment