139 lines
3.9 KiB
Bash
139 lines
3.9 KiB
Bash
|
HISTFILE=~/.histfile
|
||
|
HISTSIZE=2200
|
||
|
SAVEHIST=2000
|
||
|
setopt extendedglob
|
||
|
bindkey -v # I do vi
|
||
|
bindkey '^R' history-incremental-search-backward
|
||
|
|
||
|
autoload -Uz compinit
|
||
|
compinit
|
||
|
zstyle ':completion:*' menu select
|
||
|
zmodload zsh/complist
|
||
|
compinit
|
||
|
_comp_options+=(globdots) # Include hidden files.
|
||
|
|
||
|
# COLORS
|
||
|
autoload -U colors && colors
|
||
|
# less settings
|
||
|
export LESS='--RAW-CONTROL-CHARS --LONG-PROMPT --ignore-case --use-color'
|
||
|
# Colors in man pages
|
||
|
export MANPAGER='less -R --use-color -Dd+177 -Du+45'
|
||
|
export MANROFFOPT='-c'
|
||
|
|
||
|
# Print timing statistics of long running commands
|
||
|
REPORTTIME='10'
|
||
|
|
||
|
stty stop undef # Disable ctrl-s to freeze terminal.
|
||
|
|
||
|
## Aliases
|
||
|
|
||
|
# GNU coreutils
|
||
|
alias ls='ls --all --color=auto --classify --group-directories-first --human-readable --sort=extension'
|
||
|
alias cp='cp -i' # confirm before overwriting something
|
||
|
alias df='df -h' # human-readable sizes
|
||
|
alias du='du -h'
|
||
|
alias free='free -h'
|
||
|
# GNU grep & frontends
|
||
|
function () {
|
||
|
local grepfrontend
|
||
|
for grepfrontend in grep xzgrep zgrep zstdgrep; alias "$grepfrontend"="${grepfrontend} --color=auto"
|
||
|
}
|
||
|
|
||
|
|
||
|
## Options
|
||
|
|
||
|
# Changing Directories
|
||
|
setopt AUTO_CD
|
||
|
|
||
|
# Completion
|
||
|
setopt COMPLETE_IN_WORD
|
||
|
setopt GLOB_COMPLETE
|
||
|
setopt LIST_PACKED
|
||
|
|
||
|
# Expansion and Globbing
|
||
|
setopt EXTENDED_GLOB
|
||
|
setopt GLOB_DOTS
|
||
|
setopt WARN_CREATE_GLOBAL
|
||
|
|
||
|
# Input/Output
|
||
|
setopt CORRECT
|
||
|
setopt CORRECT_ALL
|
||
|
setopt INTERACTIVE_COMMENTS
|
||
|
setopt RM_STAR_WAIT
|
||
|
|
||
|
# Job Control
|
||
|
setopt LONG_LIST_JOBS
|
||
|
|
||
|
# Prompting
|
||
|
setopt PROMPT_SUBST
|
||
|
|
||
|
# Shell Emulation
|
||
|
setopt BSD_ECHO
|
||
|
|
||
|
## Completion
|
||
|
|
||
|
# Set up completion cache directories
|
||
|
[[ -d "${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/zcompcache" ]] || mkdir -p -- "${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/zcompcache"
|
||
|
|
||
|
autoload -Uz compinit
|
||
|
compinit -d "${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/zcompdump"
|
||
|
|
||
|
zstyle ':completion::complete:*' cache-path "${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/zcompcache"
|
||
|
zstyle ':completion::complete:*' use-cache true
|
||
|
#zstyle ':completion:*' rehash true
|
||
|
|
||
|
zstyle ':completion:*' verbose yes
|
||
|
zstyle ':completion:*' menu select=1 select=long-list
|
||
|
|
||
|
# Zsh sets directory color to red by default. Explicitly set directory color to blue when LS_COLORS is not set.
|
||
|
zstyle ':completion:*:default' list-colors "${(s.:.)LS_COLORS:-di=01;34:}"
|
||
|
|
||
|
zstyle ':completion:*' list-dirs-first true
|
||
|
zstyle ':completion:*' list-grouped true
|
||
|
zstyle ':completion:*' group-name ''
|
||
|
zstyle ':completion:*' list-suffixes true
|
||
|
|
||
|
zstyle ':completion:*:manuals' separate-sections true
|
||
|
zstyle ':completion:*:manuals.*' insert-sections true
|
||
|
|
||
|
zstyle ':completion:*:descriptions' format '%U%F{cyan}%d%f%u'
|
||
|
|
||
|
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*'
|
||
|
zstyle ':completion:*' completer _complete _ignored _correct _approximate _expand
|
||
|
|
||
|
# Ignore completion functions (until the _ignored completer)
|
||
|
zstyle ':completion:*:functions' ignored-patterns '_*'
|
||
|
|
||
|
zstyle ':completion:*:*:-command-:*:*' ignored-patterns '_*'
|
||
|
|
||
|
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
|
||
|
|
||
|
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
|
||
|
|
||
|
# Word characters are alphanumeric characters only. Despite the name it does not match the behaviour of Bash.
|
||
|
autoload -Uz select-word-style
|
||
|
select-word-style bash
|
||
|
|
||
|
## Prompt
|
||
|
|
||
|
function () {
|
||
|
local prompt_part_username='%B%F{red}%n%f$b'
|
||
|
local prompt_part_hostname='%B%F{red}%{${SSH_TTY+%B}%}%M%{${SSH_TTY+%b}%}%f%b'
|
||
|
local prompt_part_path='%F{blue}%(!.%/.%~)%f'
|
||
|
local prompt_part_priv='%#'
|
||
|
local prompt_part_exit='%F{blue}%(?..[%?])%f'
|
||
|
local prompt_part_vcs='${vcs_info_msg_0_}'
|
||
|
|
||
|
typeset -g PROMPT="${prompt_part_username}@${prompt_part_hostname} ${prompt_part_path} ${prompt_part_priv} "
|
||
|
typeset -g RPROMPT="${prompt_part_exit} ${prompt_part_vcs}"
|
||
|
}
|
||
|
|
||
|
autoload -Uz add-zsh-hook
|
||
|
|
||
|
# Version control systems
|
||
|
if (( ${+commands[git]} )); then
|
||
|
zstyle ':vcs_info:*' enable git
|
||
|
zstyle ':vcs_info:*' check-for-changes true
|
||
|
add-zsh-hook -Uz precmd vcs_info
|
||
|
fi
|