|
|
# Disable ctrl-s and ctrl-q.stty -ixon
setopt autocd autopushd \
# Enable autosuggestionssource /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zshbindkey '^ ' autosuggest-accept
# Enable colors and change promptautoload -U colors && colorsautoload -Uz vcs_infoprecmd_vcs_info() { vcs_info }precmd_functions+=( precmd_vcs_info )zstyle ':vcs_info:*' enable gitzstyle ':vcs_info:git*:*' get-revision truezstyle ':vcs_info:git*:*' check-for-changes truezstyle ':vcs_info:git*' formats "(%s) %c%u %b%m"zstyle ':vcs_info:git*' actionformats "(%s|%a) %12.12i %c%u %b%m"setopt prompt_subst# Show remote ref name and number of commits ahead-of or behindfunction +vi-git-st() { local ahead behind remote local -a gitstatus # Are we on a remote-tracking branch? remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name 2>/dev/null)/refs\/remotes\/} if [[ -n ${remote} ]] ; then # for git prior to 1.7 # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l) ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) (( $ahead )) && gitstatus+=( " ${c3}+${ahead}${c2}" ) # for git prior to 1.7 # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l) behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) (( $behind )) && gitstatus+=( "${c4}-${behind}${c2}" ) hook_com[branch]="${hook_com[branch]} [${remote}${(j:/:)gitstatus}]" fi}# Show count of stashed changesfunction +vi-git-stash() { local -a stashes if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then stashes=$(git stash list 2>/dev/null | wc -l) hook_com[misc]+=" (${stashes} stashed)" fi}zstyle ':vcs_info:git*+set-message:*' hooks git-st git-stashPS1='%B%{$fg[blue]%}[%{$fg[blue]%}%n%{$fg[blue]%}@%{$fg[blue]%}%M %{$fg[blue]%}%~%{$fg[blue]%}]%{$reset_color%}\$%b 'RPROMPT='%B%{$fg[blue]%}$vcs_info_msg_0_%{$reset_color%}%b'
# History in cache directoryHISTSIZE=10000SAVEHIST=10000
# Basic auto/tab completeautoload -U compinitzstyle ':completion:*' menu selectzstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' # Case insensitive completionzmodload zsh/complistcompinit_comp_options+=(globdots) # Include hidden files
# Enable vi modebindkey -vexport KEYTIMEOUT=1# Vim bindings in tab modebindkey -M menuselect 'h' vi-backward-charbindkey -M menuselect 'k' vi-up-line-or-historybindkey -M menuselect 'l' vi-forward-charbindkey -M menuselect 'j' vi-down-line-or-historybindkey -v '^?' backward-delete-char# Vim Cursor shapefunction zle-keymap-select { if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then echo -ne '\e[1 q' elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || [[ ${KEYMAP} == '' ]]; then echo -ne '\e[5 q' fi}zle -N zle-keymap-selectzle-line-init() { zle -K viins echo -ne "\e[5 q"}zle -N zle-line-initecho -ne '\e[5 q'preexec() { echo -ne '\e[5 q' ;}
# Vim copy and paste fix in terminalfunction x11-clip-wrap-widgets() { local copy_or_paste=$1 shift for widget in $@; do if [[ $copy_or_paste == "copy" ]]; then eval "
function _x11-clip-wrapped-$widget() { zle .$widget xclip -in -selection clipboard <<<\$CUTBUFFER } "
else eval "
function _x11-clip-wrapped-$widget() { CUTBUFFER=\$(xclip -out -selection clipboard) zle .$widget } "
fi zle -N $widget _x11-clip-wrapped-$widget done}
local copy_widgets=( vi-yank vi-yank-eol vi-delete vi-backward-kill-word vi-change-whole-line)local paste_widgets=( vi-put-{before,after})
# NB: can atm. only wrap native widgetsx11-clip-wrap-widgets copy $copy_widgetsx11-clip-wrap-widgets paste $paste_widgets
# starts one or multiple args in backgroundbackground() { for ((i=2;i<=$#;i++)); do ${@[1]} ${@[$i]} &> /dev/null &| done}
source $HOME/.config/zsh/suffixaliasrc 2>/dev/null # Load suffix aliases[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc" # Load aliases
# Load command-not-found-handlersource /usr/share/doc/pkgfile/command-not-found.zsh
# Load zsh-syntax-highlighting; should be last.source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null
if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then tmux attack-session -t $USER || tmux new-session -s $USERfi
pfetch
|