diff --git a/.config/nvim/autoload/lightline/colorscheme/plastic.vim b/.config/nvim/autoload/lightline/colorscheme/plastic.vim new file mode 100644 index 0000000..bd42c10 --- /dev/null +++ b/.config/nvim/autoload/lightline/colorscheme/plastic.vim @@ -0,0 +1,32 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/plastic.vim +" Author: Flrn Prz +" License: MIT License +" ============================================================================= +let s:foreground = [ '#a9b2c3', 235 ] +let s:background = [ '#21252b', 235 ] +let s:yellow = [ '#e5c07b', 180 ] +let s:purple = [ '#af98e6', 170 ] +let s:red = [ '#e06c75', 204 ] +let s:blue = [ '#61afef', 39 ] +let s:green = [ '#98c379', 114 ] +let s:grey = [ '#abb2bf', 59 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:foreground, s:background ], [ s:green, s:background ] ] +let s:p.normal.right = [ [ s:purple, s:background ], [ s:green, s:background ] ] +let s:p.inactive.right = [ [ s:grey, s:background ], [ s:grey, s:background ] ] +let s:p.inactive.left = [ [ s:grey, s:background ], [ s:grey, s:background ] ] +let s:p.insert.left = [ [ s:background, s:green ], [ s:green, s:background ] ] +let s:p.replace.left = [ [ s:red, s:background ], [ s:red, s:background ] ] +let s:p.visual.left = [ [ s:background, s:purple ], [ s:purple, s:background ] ] +let s:p.normal.middle = [ [ s:foreground, s:background ] ] +let s:p.inactive.middle = [ [ s:grey, s:background ] ] +let s:p.tabline.left = [ [ s:blue, s:grey ] ] +let s:p.tabline.tabsel = [ [ s:foreground, s:background ] ] +let s:p.tabline.middle = [ [ s:foreground, s:background ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:background, s:red ] ] +let s:p.normal.warning = [ [ s:background, s:yellow ] ] + +let g:lightline#colorscheme#plastic#palette = lightline#colorscheme#flatten(s:p) diff --git a/.config/nvim/colors/plastic.vim b/.config/nvim/colors/plastic.vim new file mode 100644 index 0000000..8989279 --- /dev/null +++ b/.config/nvim/colors/plastic.vim @@ -0,0 +1,270 @@ +" Vim Color File +" Name: plastic.vim +" Description: VSCode Plastic theme vim/neovim port +" Author: Florian Prz +" Repository: https://github.com/flrnprz/plastic.vim/ +" License: The MIT License (MIT) + +" Init {{{ +scriptencoding utf-8 + +set background=dark +hi clear + +if exists('syntax_on') + syntax reset +endif + +let g:colors_name = 'plastic' + +" Highlighting function (inspiration from https://github.com/chriskempson/base16-vim) +fun! hi(group, fg, bg, attr, sp) + if !empty(a:fg) + exec "hi " . a:group . " guifg=" . a:fg.gui . " ctermfg=" . a:fg.cterm256 + endif + if !empty(a:bg) + exec "hi " . a:group . " guibg=" . a:bg.gui . " ctermbg=" . a:bg.cterm256 + endif + if a:attr != "" + exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr + endif + if !empty(a:sp) + exec "hi " . a:group . " guisp=" . a:sp.gui +endif +endfun +"}}} + +" colors definition {{{ + +let s:red = {'gui': '#e06c75', 'cterm256': '204'} +let s:green = { 'gui': '#98c379', 'cterm256': '114'} +let s:yellow = { 'gui': '#e5c07b', 'cterm256': '180'} +let s:whisky = { 'gui': '#d19a66', 'cterm256': '173' } +let s:blue = { 'gui': '#61afef', 'cterm256': '39'} +let s:purple = { 'gui': '#af98e6', 'cterm256': '170'} +let s:aqua = { 'gui': '#56b6c2', 'cterm256': '38'} +let s:white = { 'gui': '#d7d7d7', 'cterm256': '145'} +let s:black = { 'gui': '#181a1f', 'cterm256': '234'} +let s:visual_black = { 'gui': 'NONE', 'cterm256': 'NONE'} +let s:background = {'gui': '#21252b', 'cterm256': '235'} +let s:foreground = {'gui': '#a9b2c3', 'cterm256': '235'} +let s:grey = { 'gui': '#abb2bf', 'cterm256': '59' } +let s:punctuation = { 'gui': '#7c8696', 'cterm256': '238' } +let s:none = {'gui': 'NONE', 'cterm256': 'NONE'} + +" }}} + +"-------------------- +" Syntax Definitions +"-------------------- +" hi(GROUP, FOREGROUND, BACKGROUND, ATTRIBUTE, SPECIAL) +call hi('Normal', s:white, s:background, 'none', {}) + +" UI {{{ +call hi('Cursor', s:none, s:none, 'inverse', {}) +hi link lCursor Cursor +hi link CursorIM Cursor +call hi('CursorLine', s:white, s:none, 'bold', {}) +call hi('EndOfBuffer', s:whisky, s:none, 'none', {}) +call hi('Conceal', s:blue, s:none, 'none', {}) +call hi('CursorColumn', s:none, s:blue, 'none', {}) +call hi('ColorColumn', s:none, s:punctuation, 'none', {}) +call hi('FoldColumn', s:punctuation, s:background, 'none', {}) +call hi('SignColumn', s:none, s:background, 'none', {}) +call hi('VertSplit', s:grey, s:background, 'none', {}) +call hi('LineNr', s:punctuation, s:background, 'none', {}) +call hi('CursorLineNr', s:punctuation, s:background, 'none', {}) + +call hi('DiffAdd', s:black, s:green, 'none', {}) +call hi('DiffChange', s:black, s:purple, 'none', {}) +call hi('DiffDelete', s:black, s:red, 'none', {}) +call hi('DiffText', s:black, s:aqua, 'none', {}) + +call hi('ErrorMsg', s:red, s:background, 'bold', {}) +call hi('ModeMsg', s:yellow, s:none, 'bold', {}) +call hi('MoreMsg', s:aqua, s:none, 'bold', {}) +call hi('WarningMsg', s:whisky, s:none, 'italic', {}) +call hi('Noise', s:punctuation, s:none, 'none', {}) +call hi('NonText', s:whisky, s:none, 'none', {}) +call hi('Folded', s:grey, s:none, 'none', {}) +call hi('IncSearch', s:yellow, s:black, 'none', {}) +call hi('Search', s:yellow, s:background, 'reverse', {}) + +call hi('Pmenu', s:none, s:black, 'none', {}) +call hi('PmenuSel', s:black, s:white, 'none', {}) + +call hi('Question', s:white, s:background, 'bold', {}) +call hi('MatchParen', s:blue, s:none, 'bold', {}) +call hi('Directory', s:white, s:background, 'bold', {}) +call hi('QuickFixLine', s:black, s:yellow, 'none', {}) + +call hi('SpecialKey', s:purple, s:none, 'none', {}) +call hi('SpellBad', s:red, s:none, 'undercurl', s:red) +call hi('SpellCap', s:none, s:none, 'undercurl', {}) +call hi('SpellLocal', s:none, s:none, 'undercurl', {}) +call hi('SpellRare', s:none, s:none, 'undercurl', {}) + +call hi('StatusLine', s:white, s:background, 'none', {}) +call hi('StatusLineNC', s:white, s:background, 'none', {}) +hi link StatusLineTerm StatusLine +hi link StatusLineTermNC StatusLineNC + +call hi('TabLine', s:white, s:black, 'none', {}) +hi link TabLineFill TabLine +call hi('TabLineSel', s:whisky, s:black, 'none', {}) + +call hi('Title', s:white, s:none, 'none', {}) +call hi('Visual', s:black, s:white, 'none', {}) +hi link VisualNOS Visual +call hi('TabLine', s:white, s:black, 'none', {}) +call hi('WildMenu', s:black, s:white, 'bold', {}) +"}}} + +"---------------------------------------------------- +" Syntax groups and naming convenions +" http://vimdoc.sourceforge.net/htmldoc/syntax.html +"---------------------------------------------------- +" {{{ +call hi('Comment', s:grey, s:none, 'italic', {}) + +call hi('Constant', s:aqua, s:none, 'none', {}) +call hi('String', s:green, s:none, 'none', {}) +hi link Character Constant +hi link Number Constant +hi link Boolean Constant +hi link Float Number + +call hi('Identifier', s:white, s:none, 'none', {}) +call hi('Function', s:whisky, s:none, 'none', {}) + +call hi('Statement', s:red, s:none, 'none', {}) +hi link Conditional Statement + +call hi('PreProc', s:aqua, s:none, 'none', {}) + +call hi('Type', s:blue, s:none, 'none', {}) + +call hi('Special', s:punctuation, s:none, 'none', {}) + +call hi('Underlined', s:blue, s:none, 'underline', {}) + +call hi('Ignore', s:none, s:none, 'none', {}) + +call hi('Error', s:red, s:black, 'undercurl', {}) + +call hi('Todo', s:aqua, s:none, 'italic', {}) + +"}}} + +"-------------------------- +" Language specific syntax +"-------------------------- + +" HTML {{{ +call hi('htmlTag', s:punctuation, s:none, 'none', {}) +hi link htmlEndTag htmlTag +call hi('htmlTagName', s:blue, s:none, 'none', {}) +call hi('htmlArg', s:whisky, s:none, 'none', {}) +call hi('htmlTitle', s:white, s:none, 'none', {}) +"}}} + +" XML {{{ +call hi('xmlRegion', s:white, s:none, 'none', {}) +hi link xmlTag xmlRegion +call hi('xmlTagName', s:yellow, s:none, 'none', {}) +call hi('xmlEndTag', s:punctuation, s:none, 'none', {}) +" }}} + +" Css {{{ +call hi('cssAttrComma', s:punctuation, s:none, 'none', {}) +call hi('cssAttributeSelector', s:green, s:none, 'none', {}) +call hi('cssBraces', s:punctuation, s:none, 'none', {}) +call hi('cssClassName', s:aqua, s:none, 'none', {}) +call hi('cssDefinition', s:purple, s:none, 'none', {}) +call hi('cssFontAttr', s:whisky, s:none, 'none', {}) +call hi('cssFontDescriptor', s:purple, s:none, 'none', {}) +call hi('cssFunctionName', s:blue, s:none, 'none', {}) +call hi('cssIdentifier', s:blue, s:none, 'none', {}) +call hi('cssImportant', s:purple, s:none, 'none', {}) +call hi('cssInclude', s:white, s:none, 'none', {}) +call hi('cssIncludeKeyword', s:red, s:none, 'none', {}) +call hi('cssMediaType', s:aqua, s:none, 'none', {}) +call hi('cssProp', s:white, s:none, 'none', {}) +call hi('cssPseudoClassId', s:whisky, s:none, 'none', {}) +call hi('cssTagName', s:whisky, s:none, 'none', {}) +call hi('cssSelectorOp', s:purple, s:none, 'none', {}) +call hi('cssSelectorOp2', s:purple, s:none, 'none', {}) +"}}} + +" Javascript {{{ +call hi('jsImport', s:red, s:none, 'none', {}) +hi link jsExport jsImport +hi link jsFrom jsImport +hi link jsExportDefault jsExport +hi link jsArrowFunction jsImport +call hi('jsStorageClass', s:blue, s:none, 'none', {}) +call hi('jsClassKeyword', s:blue, s:none, 'none', {}) +call hi('jsExtendsKeyword', s:blue, s:none, 'none', {}) +call hi('jsThis', s:yellow, s:none, 'none', {}) +"}}} + +" JSX {{{ +" https://github.com/MaxMEllon/vim-jsx-pretty +call hi('jsxTagName', s:yellow, s:none, 'none', {}) +call hi('jsxPunct', s:punctuation, s:none, 'none', {}) +call hi('jsClosePunct', s:punctuation, s:none, 'none', {}) +call hi('jsxAttrib', s:whisky, s:none, 'none', {}) +call hi('jsxComponentName', s:blue, s:none, 'none', {}) +hi link jsxCloseString jsClosePunct +"}}} + +" Golang {{{ +call hi('goDirective', s:aqua, s:none, 'none', {}) +call hi('goConstants', s:white, s:none, 'none', {}) +call hi('goDeclaration', s:red, s:none, 'none', {}) +call hi('goDeclType', s:whisky, s:none, 'none', {}) +call hi('goBuiltins', s:whisky, s:none, 'none', {}) +call hi('goFunctionCall', s:whisky, s:none, 'none', {}) +call hi('goVarAssign', s:white, s:none, 'none', {}) +hi link goVarDefs goVarAssign +"}}} + +" Markdown {{{ +call hi('markdownCode', s:green, s:none, 'none', {}) +hi link markdownCodeBlock markdownCode +hi link markdownCodeDelimiter markdownCode +call hi('markdownHeadingDelimiter', s:whisky, s:none, 'none', {}) +call hi('markdownRule', s:punctuation, s:none, 'none', {}) +call hi('markdownHeadingRule', s:punctuation, s:none, 'none', {}) +call hi('markdownH1', s:whisky, s:none, 'none', {}) +hi link markdownH2 markdownH1 +hi link markdownH3 markdownH1 +hi link markdownH4 markdownH1 +hi link markdownH5 markdownH1 +hi link markdownH6 markdownH1 +call hi('markdownIdDelimiter', s:purple, s:none, 'none', {}) +call hi('markdownId', s:purple, s:none, 'none', {}) +call hi('markdownBlockquote', s:aqua, s:none, 'none', {}) +call hi('markdowItalic', s:none, s:none, 'italic', {}) +call hi('markdownBold', s:none, s:none, 'bold', {}) +call hi('markdownListMarker', s:blue, s:none, 'none', {}) +call hi('markdownOrderedListMarker', s:blue, s:none, 'none', {}) +call hi('markdownIdDeclaration', s:blue, s:none, 'none', {}) +call hi('markdownLinkText', s:blue, s:none, 'none', {}) +call hi('markdownLinkDelimiter', s:white, s:none, 'none', {}) +call hi('markdownUrl', s:purple, s:none, 'none', {}) + +"}}} + +" NERDTree {{{ +call hi('NERDTreeDir', s:blue, s:none, 'none', {}) +call hi('NERDTreeDirSlash', s:whisky, s:none, 'none', {}) +call hi('NERDTreeFile', s:aqua, s:none, 'none', {}) +call hi('NERDTreeExecFile', s:green, s:none, 'none', {}) +call hi('NERDTreeOpenable', s:whisky, s:none, 'none', {}) +call hi('NERDTreeClosable', s:red, s:none, 'none', {}) +call hi('NERDTreeCWD', s:blue, s:none, 'bold', {}) +call hi('NERDTreeUp', s:punctuation, s:none, 'none', {}) +" }}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim new file mode 100644 index 0000000..d9fec13 --- /dev/null +++ b/.config/nvim/init.vim @@ -0,0 +1,33 @@ +" Um vim-plug zu installieren: +" curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +" Usage :PlugInstall [name] +call plug#begin() +Plug 'itchyny/lightline.vim' +"Plug 'ap/vim-css-color' " doesn't work on all files +call plug#end() + +" themes sind im Unterordner ./colors/ +colorscheme plastic +"set t_Co=256 +set termguicolors + +set number " add line numbers +set nocompatible " disable compatibility to vi +set tabstop=4 " number of columns by tab +set softtabstop=4 " see multiple spaces as tab +set expandtab " converts tab to whitespaces +set shiftwidth=4 " width for autoindents +set hlsearch " highlight search results +set showmatch " show matching brackets +set mouse=v " middle-click paste with mouse +set ignorecase " case insensitive matching +set wildmode=longest,list " bash-like tab completions +"set cc=80 " 80 column border for good coding style +syntax on " syntax highlighting + +augroup numbertoggle + autocmd! + autocmd BufEnter,FocusGained,InsertLeave * set relativenumber + autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber +augroup END + diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv new file mode 100644 index 0000000..bc8aa06 --- /dev/null +++ b/.config/zsh/.zshenv @@ -0,0 +1,16 @@ +FREECIV_DATA_PATH=$HOME/.config/freeciv + +# don't load default zshrc +setopt no_global_rcs + +# environment variables +export XDG_CONFIG_HOME="$HOME/.config" + +# move zsh config to $XDG_CONFIG_HOME +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" + +# aliases +# to temporary disable them in case they override defaults, +# use \.. , e.g. \ls +alias ls="ls -lah --color" +alias dot='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc new file mode 100644 index 0000000..dd3ab46 --- /dev/null +++ b/.config/zsh/.zshrc @@ -0,0 +1,92 @@ +#!/bin/zsh +DEFAULT_USER=marc #für den Promot wird der user ausgeblendet, wenn default erkannt ist + +# -------------------------------------- +# Environment +# -------------------------------------- + +export EDITOR=nvim +export VISUAL=nvim + +# -------------------------------------- +# Prompt +# -------------------------------------- + +setopt PROMPT_SUBST # erlaubt Funktionen im Prompt + +# -------------------------------------- +# History +# -------------------------------------- +HISTFILE=$ZDOTDIR/zhistory +setopt APPEND_HISTORY # append hostory instead of overwriting +HISTSIZE=1200 # notwendig, damit HIST_EXPIRE_DUPS_FIRST funktioniert +SAVEHIST=1000 +setopt HIST_EXPIRE_DUPS_FIRST # entfernt erst Duplikate, wenn SAVEHIST überläuft +setopt EXTENDED_HISTORY # speichert Zeitstempel und Dauer +setopt SHARE_HISTORY # share history across terms + +# -------------------------------------- +# Keybindings +# -------------------------------------- + +# create a zkbd compatible hash +# to add other keys to this hash, see: man 5 terminfo + +typeset -A key + +key[Home]="$terminfo[khome]" +key[End]="$terminfo[kend]" +key[Insert]="$terminfo[kich1]" +key[Backspace]="$terminfo[kbs]" +key[Delete]="$terminfo[kdch1]" +key[Up]="$terminfu[kcuu1]" +key[Down]="$terminfo[kcud1]" +key[Left]="$terminfo[kcub1]" +key[Right]="$terminfo[kcuf1]" +key[PageUp]="$terminfo[kpp]" +key[PageDown]="$terminfo[knp]" + +# setup key accordingly +[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line +[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line +[[ -n "${key[Insert]}" ]] && bindkey "$key[Insert]}" overwrite-mode +[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char +[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history +[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history +[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char +[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char +[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history +[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history + +bindkey "^R" history-incremental-search-backward + +# Finally, make sure the terminal is in application mode, when zle is +# active. Only then are the values from $erminfo valid. + +if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then + function zle-line-init () { + echoti smkx + } + function zle-line-finish () { + echoti rmkx + } + zle -N zle-line-init + zle -N zle-line-finish +fi + +# -------------------------------------- +# Plugins +# -------------------------------------- + +PLUGINS=$ZDOTDIR/plugins/ + +for plugin in $PLUGINS*.zsh +do + source $plugin +done + +# -------------------------------------- +# Themes +# -------------------------------------- + +source $ZDOTDIR/themes/agnoster.zsh-theme diff --git a/.config/zsh/themes/agnoster.zsh-theme b/.config/zsh/themes/agnoster.zsh-theme new file mode 100644 index 0000000..0c882bd --- /dev/null +++ b/.config/zsh/themes/agnoster.zsh-theme @@ -0,0 +1,231 @@ +#!/bin/bash + +# 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://github.com/Lokaltog/powerline-fonts). +# Make sure you have a recent version: the code points that Powerline +# uses changed in 2012, and older versions will display incorrectly, +# in confusing ways. +# +# 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' + +# Special Powerline characters + +() { + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + # NOTE: This segment separator character is correct. In 2012, Powerline changed + # the code points they use for their special characters. This is the new code point. + # If this is not working for you, you probably have an old version of the + # Powerline-patched fonts installed. Download and install the new version. + # Do not submit PRs to change this unless you have reviewed the Powerline code point + # history and have new information. + # This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of + # what font the user is viewing this source code in. Do not replace the + # escape sequence with a single literal character. + # Do not change this! Do not make it '\u2b80'; that is the old, wrong code point. + SEGMENT_SEPARATOR=$'\ue0b0' +} + +# Begin a segment +# 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() { + if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + prompt_segment black default "%(!.%{%F{yellow}%}.)$USER" + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { + (( $+commands[git] )) || return + local PL_BRANCH_CHAR + () { + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + PL_BRANCH_CHAR=$'\ue0a0' #  + } + local ref dirty mode repo_path + repo_path=$(git rev-parse --git-dir 2>/dev/null) + + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + dirty=$(parse_git_dirty) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" + if [[ -n $dirty ]]; then + prompt_segment yellow black + else + prompt_segment green black + fi + + if [[ -e "${repo_path}/BISECT_LOG" ]]; then + mode=" " + elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then + mode=" >M<" + elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then + mode=" >R>" + fi + + setopt promptsubst + autoload -Uz vcs_info + + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' get-revision true + zstyle ':vcs_info:*' check-for-changes true + zstyle ':vcs_info:*' stagedstr '✚' + zstyle ':vcs_info:*' unstagedstr '●' + zstyle ':vcs_info:*' formats ' %u%c' + zstyle ':vcs_info:*' actionformats ' %u%c' + vcs_info + echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" + fi +} + +prompt_bzr() { + (( $+commands[bzr] )) || return + if (bzr status >/dev/null 2>&1); then + status_mod=`bzr status | head -n1 | grep "modified" | wc -m` + status_all=`bzr status | head -n1 | wc -m` + revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` + if [[ $status_mod -gt 0 ]] ; then + prompt_segment yellow black + echo -n "bzr@"$revision "✚ " + else + if [[ $status_all -gt 0 ]] ; then + prompt_segment yellow black + echo -n "bzr@"$revision + + else + prompt_segment green black + echo -n "bzr@"$revision + fi + fi + fi +} + +prompt_hg() { + (( $+commands[hg] )) || return + local rev status + if $(hg id >/dev/null 2>&1); then + if $(hg prompt >/dev/null 2>&1); then + if [[ $(hg prompt "{status|unknown}") = "?" ]]; then + # if files are not added + prompt_segment red white + st='±' + elif [[ -n $(hg prompt "{status|modified}") ]]; then + # if any modification + prompt_segment yellow black + st='±' + else + # if working copy is clean + prompt_segment green black + fi + echo -n $(hg prompt "☿ {rev}@{branch}") $st + else + st="" + rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') + branch=$(hg id -b 2>/dev/null) + if `hg st | grep -q "^\?"`; then + prompt_segment red black + st='±' + elif `hg st | grep -q "^[MA]"`; then + prompt_segment yellow black + st='±' + else + prompt_segment green black + fi + echo -n "☿ $rev@$branch" $st + fi + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment blue black '%~' +} + +# Virtualenv: current working virtualenv +prompt_virtualenv() { + local virtualenv_path="$VIRTUAL_ENV" + if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then + prompt_segment blue black "(`basename $virtualenv_path`)" + fi +} + +# 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_virtualenv + prompt_context + prompt_dir + prompt_git + prompt_bzr + prompt_hg + prompt_end +} + +PROMPT='%{%f%b%k%}$(build_prompt) ' +