dotfiles

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