Created
April 14, 2020 07:07
-
-
Save msztolcman/a484674182f5c4662d3046f0c4efd2aa to your computer and use it in GitHub Desktop.
.zshrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .zshrc is sourced in interactive shells. It | |
# should contain commands to set up aliases, functions, | |
# options, key bindings, etc. | |
# | |
# Search path for the cd command | |
cdpath=(~) | |
# Use hard limits, except for a smaller stack and no core dumps | |
unlimit | |
#limit stack 8192 | |
#limit core 0 | |
limit -s | |
umask 077 | |
source ~/.aliases | |
# Shell functions | |
setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" } # csh compatibility | |
freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done } | |
# Where to look for autoloaded function definitions | |
# fpath=($fpath ~/.zfunc) | |
# fpath=(/usr/local/share/zsh-completions $fpath) | |
fpath=(/usr/local/share/zsh/site-functions $fpath) | |
# Autoload all shell functions from all directories in $fpath (following | |
# symlinks) that have the executable bit on (the executable bit is not | |
# necessary, but gives you an easy way to stop the autoloading of a | |
# particular shell function). $fpath should not be empty for this to work. | |
#for func in $^fpath/*(N-.x:t); autoload $func | |
# automatically remove duplicates from these arrays | |
typeset -U path cdpath fpath manpath | |
# Set/unset shell options | |
setopt inc_append_history | |
setopt extended_history | |
setopt no_correct | |
setopt no_correct_all | |
setopt no_match | |
setopt no_numeric_glob_sort | |
setopt no_path_dirs | |
setopt no_print_exit_value | |
setopt no_notify | |
setopt glob_dots | |
setopt pushd_to_home | |
setopt cdable_vars | |
setopt auto_list | |
setopt auto_cd | |
setopt rec_exact | |
setopt longlistjobs #? | |
setopt auto_resume #? | |
setopt hist_ignore_dups | |
setopt no_hist_ignore_all_dups | |
setopt clobber | |
setopt auto_pushd | |
setopt pushd_minus | |
setopt extended_glob | |
setopt check_jobs | |
setopt notify | |
unsetopt bgnice | |
unsetopt auto_param_slash | |
# Autoload zsh modules when they are referenced | |
zmodload -a zsh/stat stat | |
zmodload -a zsh/zpty zpty | |
zmodload -a zsh/zprof zprof | |
zmodload -ap zsh/mapfile mapfile | |
bindkey "^[e" expand-cmd-path ## C-e for expanding path of typed command | |
# bindkey "e[1;5C" forward-word # ctrl right | |
# bindkey "e[1;5D" backward-word # ctrl left | |
# Some nice key bindings | |
#bindkey '^X^Z' universal-argument ' ' magic-space | |
#bindkey '^X^A' vi-find-prev-char-skip | |
#bindkey '^Xa' _expand_alias | |
#bindkey '^Z' accept-and-hold | |
#bindkey -s '\M-/' \\\\ | |
#bindkey -s '\M-=' \| | |
#bindkey -v # vi key bindings | |
bindkey -e # emacs key bindings | |
bindkey ' ' magic-space # also do history expansion on space | |
bindkey '^I' complete-word # complete on tab, leave expansion to _expand | |
# Setup new style completion system. To see examples of the old style (compctl | |
# based) programmable completion, check Misc/compctl-examples in the zsh | |
# distribution. | |
autoload -U compinit | |
compinit | |
## This allows incremental completion of a word. | |
## After starting this command, a list of completion | |
## choices can be shown after every character you | |
## type, which you can delete with ^h or DEL. | |
## RET will accept the completion so far. | |
## You can hit TAB to do normal completion, ^g to | |
## abort back to the state when you started, and ^d to list the matches. | |
autoload -U incremental-complete-word | |
zle -N incremental-complete-word | |
bindkey "^Xi" incremental-complete-word ## C-x-i | |
## This function allows you type a file pattern, | |
## and see the results of the expansion at each step. | |
## When you hit return, they will be inserted into the command line. | |
autoload -U insert-files | |
zle -N insert-files | |
bindkey "^Xf" insert-files ## C-x-f | |
# wyszukiwanie w historii po wpisaniu części polecenia wpisywanego wcześniej, i strzałka w górę/dół | |
bindkey '^[[A' history-beginning-search-backward | |
bindkey '^[[B' history-beginning-search-forward | |
# Completion Styles | |
# list of completers to use | |
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate | |
# allow one error for every three characters typed in approximate completer | |
zstyle -e ':completion:*:approximate:*' max-errors \ | |
'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )' | |
# insert all expansions for expand completer | |
zstyle ':completion:*:expand:*' tag-order all-expansions | |
# formatting and messages | |
zstyle ':completion:*' verbose yes | |
zstyle ':completion:*:descriptions' format '%B%d%b' | |
zstyle ':completion:*:messages' format '%d' | |
zstyle ':completion:*:warnings' format 'No matches for: %d' | |
#zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b' | |
zstyle ':completion:*' group-name '' | |
# match uppercase from lowercase | |
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' | |
# offer indexes before parameters in subscripts | |
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters | |
# command for process lists, the local web server details and host completion | |
#zstyle ':completion:*:processes' command 'ps -o pid,s,nice,stime,args' | |
#zstyle ':completion:*:urls' local 'www' '/var/www/htdocs' 'public_html' | |
# Hosts to use for completion | |
hosts=() | |
zstyle '*' hosts $hosts | |
## (user,host) pairs | |
## all my accounts: | |
my_accounts=( | |
) | |
zstyle ':completion:*:my-accounts' users-hosts $my_accounts | |
# Filename suffixes to ignore during completion (except after rm command) | |
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \ | |
'*?.old' '*?.pro' | |
# the same for old style completion | |
#fignore=(.o .c~ .old .pro) | |
# ignore completion functions (until the _ignored completer) | |
zstyle ':completion:*:functions' ignored-patterns '_*' | |
## completion caching | |
zstyle ':completion::complete:*' use-cache 1 | |
zstyle ':completion::complete:*' cache-path ~/.zcompcache/$HOST | |
# pip zsh completion start | |
function _pip_completion { | |
local words cword | |
read -Ac words | |
read -cn cword | |
reply=( $( COMP_WORDS="$words[*]" \ | |
COMP_CWORD=$(( cword-1 )) \ | |
PIP_AUTO_COMPLETE=1 $words[1] ) ) | |
} | |
compctl -K _pip_completion pip | |
# pip zsh completion end | |
# add colors | |
# if [ -x dircolors ]; then | |
# eval `dircolors ~/.dir_colors` | |
# elif [ -x /usr/local/bin/gdircolors ]; then | |
# eval `/usr/local/bin/gdircolors ~/.dir_colors` | |
# fi | |
# LSCOLORS=$LS_COLORS | |
# http://geoff.greer.fm/lscolors/ | |
export LS_COLORS="di=45;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=36;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:" | |
export LSCOLORS="gxfxcxdxbxegbgabaghcad" | |
zstyle ':completion:*:default' list-colors ${(s.:.)LSCOLORS} | |
chpwd() { | |
[[ -t 1 ]] || return | |
case $TERM in | |
sun-cmd) print -Pn "\e]l%~\e\\" | |
;; | |
*xterm*|rxvt|(dt|k|E)term) print -Pn "\e]2;%~\a" | |
;; | |
esac | |
} | |
autoload -Uz vcs_info | |
setopt prompt_subst | |
autoload -Uz vcs_info | |
zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' | |
zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f ' | |
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' | |
zstyle ':vcs_info:*' enable git cvs svn | |
# or use pre_cmd, see man zshcontrib | |
vcs_info_wrapper() { | |
vcs_info | |
if [ -n "$vcs_info_msg_0_" ]; then | |
echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del" | |
fi | |
} | |
autoload -U colors && colors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment