From ccf94b7df09799feb201d1a59928932fda4e24f4 Mon Sep 17 00:00:00 2001 From: David Runge Date: Fri, 31 Oct 2014 18:30:03 +0100 Subject: zsh: Adding config files for zprezto, zsh settings and prompts, to comply with the way zprezto gets started --- .zsh.prompts/prompt_agnoster_setup | 141 ++++++++++++++++++++++++++++ .zsh.prompts/prompt_kylewest_setup | 57 +++++++++++ .zsh.prompts/prompt_skwp_setup | 74 +++++++++++++++ .zsh.prompts/prompt_steeef_simplified_setup | 98 +++++++++++++++++++ 4 files changed, 370 insertions(+) create mode 100644 .zsh.prompts/prompt_agnoster_setup create mode 100644 .zsh.prompts/prompt_kylewest_setup create mode 100644 .zsh.prompts/prompt_skwp_setup create mode 100644 .zsh.prompts/prompt_steeef_simplified_setup (limited to '.zsh.prompts') diff --git a/.zsh.prompts/prompt_agnoster_setup b/.zsh.prompts/prompt_agnoster_setup new file mode 100644 index 0000000..16d18c9 --- /dev/null +++ b/.zsh.prompts/prompt_agnoster_setup @@ -0,0 +1,141 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' +SEGMENT_SEPARATOR='⮀' + +# Customizations + +# Checks if working tree is dirty +# From robbyrussell/oh-my-zsh +parse_git_dirty() { + local SUBMODULE_SYNTAX='' + local GIT_STATUS='' + local CLEAN_MESSAGE='nothing to commit (working directory clean)' + if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then + if [[ $POST_1_7_2_GIT -gt 0 ]]; then + SUBMODULE_SYNTAX="--ignore-submodules=dirty" + fi + if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) + else + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) + fi + if [[ -n $GIT_STATUS ]]; then + echo "$ZSH_THEME_GIT_PROMPT_DIRTY" + else + echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + fi + else + echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + fi +} + +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " + else + echo -n "%{$bg%}%{$fg%} " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -n "%{%k%}" + fi + echo -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + local user=`whoami` + + if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m" + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { + local ref dirty + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + ZSH_THEME_GIT_PROMPT_DIRTY='±' + dirty=$(parse_git_dirty) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + if [[ -n $dirty ]]; then + prompt_segment yellow black + else + prompt_segment green black + fi + echo -n "${ref/refs\/heads\//⭠ }$dirty" + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment blue black '%~' +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" +} + +## Main prompt +build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_end +} + +PROMPT='%{%f%b%k%}$(build_prompt) ' diff --git a/.zsh.prompts/prompt_kylewest_setup b/.zsh.prompts/prompt_kylewest_setup new file mode 100644 index 0000000..c67b5e4 --- /dev/null +++ b/.zsh.prompts/prompt_kylewest_setup @@ -0,0 +1,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 +# Kyle West + +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 "$@" diff --git a/.zsh.prompts/prompt_skwp_setup b/.zsh.prompts/prompt_skwp_setup new file mode 100644 index 0000000..c45eb8a --- /dev/null +++ b/.zsh.prompts/prompt_skwp_setup @@ -0,0 +1,74 @@ +# +# A theme based on steeef theme +# * RVM/Rbenv info shown on the right +# * Git branch info on the left +# * Single line prompt +# +# Authors: +# Steve Losh +# Bart Trojanowski +# Brian Carper +# steeef +# Sorin Ionescu +# Yan Pritzker + +function prompt_skwp_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_skwp_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + autoload -Uz add-zsh-hook + + add-zsh-hook precmd prompt_skwp_precmd + + # Use extended color pallete if available. + if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then + __PROMPT_SKWP_COLORS=( + "%F{81}" # turquoise + "%F{166}" # orange + "%F{135}" # purple + "%F{161}" # hotpink + "%F{118}" # limegreen + ) + else + __PROMPT_SKWP_COLORS=( + "%F{cyan}" + "%F{yellow}" + "%F{magenta}" + "%F{red}" + "%F{green}" + ) + fi + + # git + zstyle ':prezto:module:git:info:branch' format "${__PROMPT_SKWP_COLORS[1]}%b%f" + zstyle ':prezto:module:git:info:added' format "${__PROMPT_SKWP_COLORS[5]}●%f" + zstyle ':prezto:module:git:info:deleted' format "${__PROMPT_SKWP_COLORS[2]}●%f" + zstyle ':prezto:module:git:info:modified' format "${__PROMPT_SKWP_COLORS[4]}●%f" + zstyle ':prezto:module:git:info:untracked' format "${__PROMPT_SKWP_COLORS[3]}●%f" + zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%d%a%m%u)' + + # ruby info (rvm, rbenv) + zstyle ':prezto:module:ruby:info:version' format '[%v]' + + PROMPT="${__PROMPT_SKWP_COLORS[3]}%n%f@${__PROMPT_SKWP_COLORS[2]}%m%f ${__PROMPT_SKWP_COLORS[5]}%~%f "'$git_info[prompt]'"$ " + RPROMPT='%F{blue}${ruby_info[version]}' +} + +prompt_skwp_setup "$@" diff --git a/.zsh.prompts/prompt_steeef_simplified_setup b/.zsh.prompts/prompt_steeef_simplified_setup new file mode 100644 index 0000000..14b16da --- /dev/null +++ b/.zsh.prompts/prompt_steeef_simplified_setup @@ -0,0 +1,98 @@ +# +# A theme based on Steve Losh's Extravagant Prompt with vcs_info integration. +# +# Authors: +# Steve Losh +# Bart Trojanowski +# Brian Carper +# steeef_simplified +# Sorin Ionescu +# +# Screenshots: +# http://i.imgur.com/HyRvv.png +# + +function prompt_steeef_simplified_precmd { + # Check for untracked files or updated submodules since vcs_info does not. + if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then + branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c${_prompt_steeef_simplified_colors[4]}●%f)" + else + branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c)" + fi + + zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" + + vcs_info 'prompt' + + if (( $+functions[python-info] )); then + python-info + fi + + # Get ruby information + if (( $+functions[ruby-info] )); then + ruby-info + fi +} + +function prompt_steeef_simplified_setup { + setopt LOCAL_OPTIONS + unsetopt XTRACE KSH_ARRAYS + prompt_opts=(cr percent subst) + + # Load required functions. + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + + # Add hook for calling vcs_info before each command. + add-zsh-hook precmd prompt_steeef_simplified_precmd + + # Use extended color pallete if available. + if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then + _prompt_steeef_simplified_colors=( + "%F{81}" # Turquoise + "%F{166}" # Orange + "%F{135}" # Purple + "%F{161}" # Hotpink + "%F{118}" # Limegreen + ) + else + _prompt_steeef_simplified_colors=( + "%F{cyan}" + "%F{yellow}" + "%F{magenta}" + "%F{red}" + "%F{green}" + ) + fi + + # Formats: + # %b - branchname + # %u - unstagedstr (see below) + # %c - stagedstr (see below) + # %a - action (e.g. rebase-i) + # %R - repository path + # %S - path in the repository + local branch_format="(${_prompt_steeef_simplified_colors[1]}%b%f%u%c)" + local action_format="(${_prompt_steeef_simplified_colors[5]}%a%f)" + local unstaged_format="${_prompt_steeef_simplified_colors[2]}●%f" + local staged_format="${_prompt_steeef_simplified_colors[5]}●%f" + + # Set vcs_info parameters. + zstyle ':vcs_info:*' enable bzr git hg svn + zstyle ':vcs_info:*:prompt:*' check-for-changes true + zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}" + zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}" + zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}" + zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" + zstyle ':vcs_info:*:prompt:*' nvcsformats "" + + # Set python-info parameters. + zstyle ':prezto:module:python:info:virtualenv' format '(%v)' + + # Define prompts. + PROMPT="${_prompt_steeef_simplified_colors[3]}%n%f@${_prompt_steeef_simplified_colors[2]}%m%f ${_prompt_steeef_simplified_colors[5]}%~%f "'${vcs_info_msg_0_}'"$ " + RPROMPT='%F{blue}${ruby_info[version]}' +} + +prompt_steeef_simplified_setup "$@" + -- cgit v1.2.3-54-g00ecf