]> git.friedersdorff.com Git - max/saltfiles.git/blob - states/zsh/files/zshrc
2d92fd4c4dc8bb32b0fcfd5d281544fb319d65f4
[max/saltfiles.git] / states / zsh / files / zshrc
1 # The following lines were added by compinstall
2
3 zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
4 zstyle ':completion:*' completions 1
5 zstyle ':completion:*' expand suffix
6 zstyle ':completion:*' glob 1
7 zstyle ':completion:*' ignore-parents parent pwd
8 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
9 zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
10 zstyle ':completion:*' list-suffixes true
11 zstyle ':completion:*' max-errors 1
12 zstyle ':completion:*' menu select=1
13 zstyle ':completion:*' preserve-prefix '//[^/]##/'
14 zstyle ':completion:*' prompt 'Corrections with %e differences:'
15 zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
16 zstyle ':completion:*' substitute 1
17 zstyle :compinstall filename '/home/max/.zshrc'
18
19 autoload -Uz compinit
20 compinit
21 # End of lines added by compinstall
22 # Lines configured by zsh-newuser-install
23 HISTFILE=~/.histfile
24 HISTSIZE=100000
25 SAVEHIST=100000
26 setopt appendhistory autocd extendedglob nomatch extendedhistory correct
27 unsetopt beep notify
28 bindkey -v
29 # End of lines configured by zsh-newuser-install
30
31 # Prompt
32 NEWLINE=$'\n'
33 setopt prompt_subst
34
35
36 p="%(?;%F{green};%F{red})[%h]%f "
37 p+="%F{red}%B%n%b%f@%F{red}%B%m%b%f"
38 p+=":%F{blue}%~%f"
39 p+="${NEWLINE}%(!.#.$) "
40
41 virtual_env() {
42         if [ -n "${VIRTUAL_ENV+1}" ]; then
43                 home_rel_path=$(echo ${VIRTUAL_ENV} | sed "s;^${HOME};~;")
44                 echo -n "(${home_rel_path}) "
45         fi
46 }
47
48 source ~/.git-prompt.sh
49 precmd () {
50         __git_ps1 "" "$(virtual_env)${p}" "${NEWLINE}[%s]${NEWLINE}"
51 }
52
53 bindkey '^R' history-incremental-search-backward
54
55 if [[ -f ~/.shell_aliases ]]; then
56         source ~/.shell_aliases
57 fi
58
59 export WORKON_HOME=~/.virtualenvs
60 source /usr/bin/virtualenvwrapper_lazy.sh
61
62 chpwd() {
63     src_dir="$(readlink -f ~/src/)/"
64     if [[ $PWD == "$src_dir"* ]]; then
65         if git status &>/dev/null; then
66             venv_name=$(basename $(git rev-parse --show-toplevel))
67             if [[ -n "$VIRTUAL_ENV" ]]; then
68                 current_venv_name=$(basename "$VIRTUAL_ENV")
69                 if [[ "$current_venv_name" != "$venv_name" ]]; then
70                     deactivate
71                     workon "$venv_name"
72                 fi
73             else
74                 if workon | grep -q "$venv_name"; then
75                     workon "$venv_name"
76                 fi
77             fi
78         else
79             if [[ -n "$VIRTUAL_ENV" ]]; then
80                 deactivate
81             fi
82         fi
83     else
84         if [[ -n "$VIRTUAL_ENV" ]]; then
85             deactivate
86         fi
87     fi
88 }
89
90 export GPG_TTY=$(tty)
91 gpg-connect-agent updatestartuptty /bye >/dev/null
92
93 ZSH_AUTOSUGGEST_STRATEGY=(history completion)
94 ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=30
95
96 source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
97 source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh