dotfiles

My dotfiles for Arch Linux
git clone git://git.janispagel.de/dotfiles.git
Log | Files | Refs | README

dot-zshrc (7666B)


      1 #################
      2 ### Functions ###
      3 #################
      4 
      5 # Source functions
      6 if [ -f ~/.zsh_functions ]; then
      7   source ~/.zsh_functions
      8 fi
      9 
     10 ########################
     11 #### Key bindings ######
     12 ########################
     13 
     14 bindkey '^[[P' delete-char # Delete
     15 bindkey '^[[5~' up-line-or-history # PageUp
     16 bindkey '^[[6~' down-line-or-history # PageDown
     17 
     18 ########################
     19 #### Autocomplete ######
     20 ########################
     21 
     22 # Perform some sanity checks on completion option
     23 autoload -Uz compinit
     24 compinit
     25 
     26 bindkey '^i' expand-or-complete-prefix # Complete inside of string
     27 zstyle ':completion:*' completer _complete _match _approximate # Enable fuzzy matching
     28 zstyle ':completion:*:match:*' original only
     29 zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )' # Tolerance of approximate increases by amount of characters typed so far
     30 zstyle ':completion:*:(rm|kill|diff):*' ignore-line yes # Avoid getting the same file offered again with certain programs
     31 zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
     32 zstyle ':completion:*:descriptions' format "- %d -"
     33 zstyle ':completion:*:corrections' format "- %d - (errors %e})"
     34 zstyle ':completion:*:default' list-prompt '%S%M matches%s'
     35 zstyle ':completion:*' group-name ''
     36 zstyle ':completion:*:manuals' separate-sections true
     37 zstyle ':completion:*:manuals.(^1*)' insert-sections true
     38 zstyle ':completion:*:ssh:*' hosts off # Do not use /etc/hosts in ssh autocompletion
     39 zstyle ':completion:*:scp:*' hosts off # Do not use /etc/hosts in scp autocompletion
     40 zstyle ':completion:*' menu select
     41 zstyle ':completion:*' verbose yes
     42 zstyle ':completion:*' rehash true
     43 # Speed up completion by setting cache
     44 zstyle ':completion:*' use-cache on
     45 zstyle ':completion:*' cache-path ~/.zsh/cache
     46 
     47 #######################
     48 ### Options ###########
     49 #######################
     50 
     51 setopt CORRECT # Make suggestions for correcting spelling mistakes
     52 setopt EXTENDED_GLOB # Inlude ~ in globbing
     53 setopt CASE_GLOB # Case sensitive globbing
     54 setopt GLOB_COMPLETE # Use pattern matching for wildcards and ~
     55 setopt NUMERIC_GLOB_SORT # Sort numerically if numbers are present in globbing
     56 setopt RC_EXPAND_PARAM # Expand globbing arrays to full names
     57 setopt NO_BEEP # Disable system beeps
     58 setopt MARK_DIRS # Always append trailing / to dirs
     59 setopt APPEND_HISTORY # Append to history file instead of overwriting
     60 setopt HIST_IGNORE_ALL_DUPS # Ignore all history dups
     61 setopt AUTO_CD # No need to type 'cd' if standard input is a valid path
     62 setopt PROMPT_SUBST # Enable command substitution in prompt
     63 
     64 ##########################
     65 ######## Basics ##########
     66 ##########################
     67 
     68 # Set history options
     69 HISTFILE=~/.zhistory
     70 HISTSIZE=1000000
     71 SAVEHIST=1000000
     72 
     73 # Source aliases
     74 if [ -f ~/.zsh_aliases ]; then
     75     source ~/.zsh_aliases
     76 fi
     77 
     78 # Use fish-like history substring search
     79 if [ -f /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh ]; then
     80     source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
     81     # bind UP and DOWN arrow keys to history substring search
     82     zmodload zsh/terminfo
     83     bindkey "$terminfo[kcuu1]" history-substring-search-up
     84     bindkey "$terminfo[kcud1]" history-substring-search-down
     85     bindkey '^[[A' history-substring-search-up
     86     bindkey '^[[B' history-substring-search-down
     87 fi
     88 # Use fish-like autosuggestion
     89 if [ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
     90 	source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
     91 	ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
     92 	ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=2'
     93 fi
     94 # Use fish-like syntax highlighting
     95 #if [ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then
     96 #	source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
     97 #fi
     98 # fzf file history
     99 if [ -f /usr/share/fzf/key-bindings.zsh ]; then
    100 	source /usr/share/fzf/key-bindings.zsh
    101 fi
    102 
    103 ######################
    104 ####### Prompt #######
    105 ######################
    106 
    107 # set left prompt
    108 PROMPT='%(!.#.$>) %E'
    109 
    110 ######
    111 # This whole git prompt stuff was taken from Manjaro's zsh setup, slightly modified
    112 ######
    113 
    114 # Modify the colors and symbols in these variables as desired.
    115 GIT_PROMPT_SYMBOL=""                                            # clean repo
    116 GIT_PROMPT_PREFIX="["
    117 GIT_PROMPT_SUFFIX="]"
    118 GIT_PROMPT_AHEAD="ANUM"                                         # A"NUM" - ahead by "NUM" commits
    119 GIT_PROMPT_BEHIND="BNUM"                                        # B"NUM" - behind by "NUM" commits
    120 GIT_PROMPT_MERGING="%F{1}!%f"                                   # merge conflict
    121 GIT_PROMPT_UNTRACKED="%F{1}++%f"                                # untracked files
    122 GIT_PROMPT_MODIFIED="%F{3}+%f"                                  # tracked files modified
    123 GIT_PROMPT_STAGED="%F{2}->%f"                                   # staged changes present = ready for "git push"
    124 
    125 # Right prompt with exit status of previous command if not successful
    126 # Also show background process, git information and current dir
    127 RPROMPT='$(bg_process) $(git_prompt_string) %(?..[%?]) [%1~/]'
    128 
    129 #################
    130 ##### Misc ######
    131 #################
    132 
    133 # TMUX
    134 if [[ -z $TMUXAUTOATTACH ]]; then # Prevent from running if variable is set
    135     if [[ -z "$TMUX" ]] && [[ -n "$DISPLAY" ]]; then # Test if tmux is running
    136         ID="$( tmux ls | grep -vm1 attached | cut -d: -f1 )" # get the id of a deattached session
    137         if [[ -z "$ID" ]]; then # if not available create a new one
    138             tmux new-session
    139         else
    140             tmux attach-session -t "$ID" # if available attach to it
    141         fi
    142     fi
    143 fi
    144 if [ -n "$TMUX" ]; then # If tmux is running
    145     # create a global per-pane variable that holds the pane's PWD
    146     export PS1=$PS1'$( [ -n $TMUX ] && tmux setenv -g TMUX_PWD_$(tmux display -p "#D" | tr -d %) $PWD)'
    147 fi
    148 
    149 # Color man pages
    150 export LESS_TERMCAP_mb=$'\E[01;32m'
    151 export LESS_TERMCAP_md=$'\E[01;32m'
    152 export LESS_TERMCAP_me=$'\E[0m'
    153 export LESS_TERMCAP_se=$'\E[0m'
    154 export LESS_TERMCAP_so=$'\E[01;47;34m'
    155 export LESS_TERMCAP_ue=$'\E[0m'
    156 export LESS_TERMCAP_us=$'\E[01;36m'
    157 export LESS=-r
    158 
    159 # Load DIRCOLORS
    160 test -r "~/.dir_colors" && eval $(dircolors ~/.dir_colors)
    161 
    162 # Add support for GnuPG
    163 export GPG_TTY=$(tty)
    164 
    165 # Disable graphical interface for SSH password
    166 unset SSH_ASKPASS
    167 
    168 # Customize tty
    169 if [ "$TERM" = "linux" ]; then
    170 	printf '\033]P03b4252'; # black
    171 	printf '\033]P1bf616a'; # red
    172 	printf '\033]P2a3be8c'; # green
    173 	printf '\033]P3ebcb8b'; # yellow
    174 	printf '\033]P481a1c1'; # blue
    175 	printf '\033]P5b48ead'; # magenta
    176 	printf '\033]P688c0d0'; # cyan
    177 	printf '\033]P7e5e9f0'; # white
    178 	printf '\033]P84c566a'; # bright black
    179 	printf '\033]P9bf616a'; # bright red
    180 	printf '\033]PAa3be8c'; # bright green
    181 	printf '\033]PBebcb8b'; # bright yellow
    182 	printf '\033]PC81a1c1'; # bright blue
    183 	printf '\033]PDb48ead'; # bright magenta
    184 	printf '\033]PE8fbcbb'; # bright cyan
    185 	printf '\003]PFeceff4'; # bright white
    186 	clear;
    187 	if [ -f "/usr/share/kbd/consolefonts/ter-v24n.psf.gz" ]; then
    188 		setfont ter-v24n
    189 	fi
    190 fi
    191 
    192 # added by travis gem
    193 [ -f /home/janis/.travis/travis.sh ] && source /home/janis/.travis/travis.sh
    194 
    195 # >>> conda initialize >>>
    196 # !! Contents within this block are managed by 'conda init' !!
    197 __conda_setup="$('/home/janis/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
    198 if [ $? -eq 0 ]; then
    199     eval "$__conda_setup"
    200 else
    201     if [ -f "/home/janis/anaconda3/etc/profile.d/conda.sh" ]; then
    202         . "/home/janis/anaconda3/etc/profile.d/conda.sh"
    203     else
    204         export PATH="/home/janis/anaconda3/bin:$PATH"
    205     fi
    206 fi
    207 unset __conda_setup
    208 # <<< conda initialize <<<
    209 
    210 # Start X in tty2
    211 if [[ "$(tty)" = "/dev/tty2" ]]; then
    212 	pgrep dwm || startx
    213 fi