repos/dotfiles

Config files from my daily system
Commits Files Refs README
.zshrc (210 lines)
   1 #                 _
   2 #         _______| |__  _ __ ___
   3 #        |_  / __| '_ \| '__/ __|
   4 #         / /\__ \ | | | | | (__
   5 #        /___|___/_| |_|_|  \___|
   6 #
   7 #         by github.com/klewer-martin
   8 #
   9 
  10 HISTFILE=$HOME/.cache/zsh_history
  11 HISTSIZE=1000000
  12 SAVEHIST=$HISTSIZE
  13 ZDOTDIR=$HOME/.config/zsh
  14 
  15 # Do not save less pager history file
  16 LESSHISTFILE=/dev/null
  17 
  18 setopt inc_append_history
  19 setopt hist_ignore_all_dups
  20 setopt share_history
  21 setopt interactivecomments
  22 setopt autocd
  23 setopt nohup
  24 # setopt nopromptcr
  25 setopt correct
  26 setopt noclobber
  27 setopt nolistambiguous
  28 setopt extended_glob
  29 
  30 # If not running interactively, don't do anything
  31 [[ $- != *i* ]] && return
  32 
  33 # Add plugins (because I don't use a plugin manager)
  34 source $HOME/.config/zsh/plugged/zsh-autosuggestions/zsh-autosuggestions.zsh
  35 unset ZSH_AUTOSUGGEST_USE_ASYNCS
  36 # bindkey '^ ' autosuggest-fetch
  37 bindkey '^n' autosuggest-accept
  38 
  39 source $HOME/.config/zsh/plugged/zsh-history-substring-search/zsh-history-substring-search.zsh
  40 
  41 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#ff0000'
  42 # ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline"
  43 
  44 # Add my personal scripts folder to path
  45 PATH="$PATH:$HOME/.local/bin/statusbar:$HOME/.local/bin/statusbar/buttons:$HOME/.local/bin:$HOME/go/bin:/usr/local/go/bin"
  46 
  47 # Set enviroment variables
  48 export EDITOR=/usr/bin/nvim
  49 export BROWSER=/usr/bin/firefox
  50 export TERM='xterm-256color'
  51 export LC_TIME="es_AR.UTF-8" # dd/mm/yy time format
  52 
  53 # PROMPT_EOL_MARK=''
  54 
  55 # vi mode
  56 bindkey -v
  57 export KEYTIMEOUT=1
  58 
  59 bindkey -M emacs '^?' backward-kill-word
  60 bindkey -M viins '^?' backward-kill-word
  61 bindkey -M vicmd '^?' backward-kill-word
  62 
  63 bindkey -M emacs '^[[3;5~' kill-word
  64 bindkey -M viins '^[[3;5~' kill-word
  65 bindkey -M vicmd '^[[3;5~' kill-word
  66 
  67 # yank to the system clipboard
  68 function vi-yank-xclip {
  69     zle vi-yank
  70    echo "$CUTBUFFER" | xclip -selection clipboard
  71 }
  72 
  73 zle -N vi-yank-xclip
  74 bindkey -M vicmd 'y' vi-yank-xclip
  75 
  76 # Basic auto/tab complete:
  77 autoload -U compinit
  78 zstyle ':completion:*' menu select
  79 zstyle :compinstall filename '$HOME/.zshrc'
  80 zmodload zsh/complist
  81 compinit
  82 _comp_options+=(globdots)        # Include hidden files.
  83 
  84 # Use vim keys in tab complete menu:
  85 bindkey -M menuselect 'h' vi-backward-char
  86 bindkey -M menuselect 'k' vi-up-line-or-history
  87 bindkey -M menuselect 'l' vi-forward-char
  88 bindkey -M menuselect 'j' vi-down-line-or-history
  89 
  90 bindkey -v '^?' backward-delete-char
  91 # bindkey '^R' history-incremental-pattern-search-backward
  92 
  93 # Search backwards and forwards with a pattern
  94 bindkey -M vicmd '/' history-incremental-pattern-search-backward
  95 bindkey -M vicmd '?' history-incremental-pattern-search-forward
  96 
  97 # set up for insert mode too
  98 bindkey -M viins '^R' history-incremental-pattern-search-backward
  99 bindkey -M viins '^F' history-incremental-pattern-search-forward
 100 
 101 # Change cursor shape for different vi modes.
 102 function zle-keymap-select {
 103   if [[ ${KEYMAP} == vicmd ]] ||
 104      [[ $1 = 'block' ]]; then
 105     echo -ne '\e[1 q'
 106   elif [[ ${KEYMAP} == main ]] ||
 107        [[ ${KEYMAP} == viins ]] ||
 108        [[ ${KEYMAP} = '' ]] ||
 109        [[ $1 = 'beam' ]]; then
 110     echo -ne "\e[5 q"
 111   fi
 112 }
 113 zle -N zle-keymap-select
 114 
 115 zle-line-init() {
 116     zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
 117     echo -ne "\e[5 q"
 118 }
 119 zle -N zle-line-init
 120 
 121 echo -ne '\e[5 q' # Use beam shape cursor on startup.
 122 preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
 123 
 124 # This is for ranger to display previews properly
 125 set preview_images_method ueberzug
 126 
 127 # Load colors and set a colored prompt:
 128 autoload -U colors && colors
 129 
 130 # Shows jobs in background number
 131 PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[magenta]%}%M %{$fg[cyan]%}%1~%{$fg[red]%}]%(1j.%F{011}(%j)%f.)%{$reset_color%}%(?..%{$fg[red]%})$%{$reset_color%} "
 132 
 133 # Right prompt
 134 # RPS1="hola"
 135 
 136 # Edit line in vim with ctrl-e:
 137 autoload edit-command-line; zle -N edit-command-line
 138 bindkey '^e' edit-command-line
 139 # bindkey -s '^e' 'cd "$(dirname "$(fzf)")"\n'
 140 
 141 # This fix my keybord in terminal; (I use st)
 142 autoload -Uz up-line-or-beginning-search
 143 autoload -Uz down-line-or-beginning-search
 144 zle -N up-line-or-beginning-search
 145 zle -N down-line-or-beginning-search
 146 
 147 bindkey '^[[P'    delete-char                    # delete      delete previous char
 148 bindkey '^[[3~'   delete-char                    # delete      delete previous char
 149 bindkey '^[[H'    beginning-of-line             # home       go to the beginning of line
 150 bindkey '^[[F'    end-of-line                   # end        go to the end of line
 151 bindkey '^[[1;5C' forward-word                  # ctrl+right go forward one word
 152 bindkey '^[[1;5D' backward-word                 # ctrl+left  go backward one word
 153 bindkey '^H'      backward-kill-word            # ctrl+bs    delete previous word
 154 bindkey '^[[M'      kill-word                     # ctrl+del   delete next word
 155 
 156 # Source aliases file
 157 source $HOME/.config/zsh/aliases.sh
 158 
 159 # Dynamic window title with zsh shell.
 160 # Shows current directory and running (multi-line) command.
 161 case "$TERM" in (rxvt|rxvt-*|st|st-*|*xterm*|(dt|k|E)term)
 162     local term_title () { print -n "\e]0;${(j: :q)@}\a" }
 163     precmd () {
 164       local DIR="$(print -P '%~ $')"
 165       term_title "$DIR" "zsh"
 166     }
 167     preexec () {
 168       local DIR="$(print -P '%~ $')"
 169       local CMD="${(j:\n:)${(f)1}}"
 170       term_title "$DIR" "$CMD"
 171     }
 172   ;;
 173 esac
 174 
 175 # Starts the X server:
 176 if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
 177     startx 2> /dev/null
 178 logout
 179 fi
 180 
 181 # Enable mouse support for less pager on tmux
 182 [[ ! -z "$TMUX" ]] && export LESS='--mouse -Rf'
 183 
 184 # Default arguments for fzf
 185 export FZF_DEFAULT_OPTS='--height=8 --layout=reverse --border=sharp'
 186 
 187 # . $HOME/mouse.zsh
 188 
 189 # M for vi (cmd) mode
 190 bindkey -M vicmd M zle-toggle-mouse
 191 
 192 # zstyle ':completion:*' menu select script /usr/local/etc/bash_completion.d/git-completion.bash
 193 
 194 # unambigandmenu() {
 195 #     zle expand-or-complete
 196 #     zle magic-space
 197 #     zle backward-delete-char
 198 #     zle expand-or-complete
 199 # }
 200 # zle -N unambigandmenu
 201 
 202 # zstyle -e ':completion:*' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==03=01}:${(s.:.)LS_COLORS}")'
 203 # zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==34=00}:${(s.:.)LS_COLORS}")';
 204 pfetch
 205 
 206 source $HOME/.config/zsh/plugged/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
 207 ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=#ff0000'
 208 # ZSH_HIGHLIGHT_STYLES[comment]='fg=grey,bold'
 209 ZSH_HIGHLIGHT_STYLES[comment]='fg=#707070,bold'
 210