136 lines
3.3 KiB
Bash
136 lines
3.3 KiB
Bash
## -*- mode:sh -*- #
|
|
## Zsh specific options
|
|
|
|
ZCACHE=~/.cache/zsh/
|
|
[ ! -e "$ZCACHE" ] && mkdir -p "$ZCACHE"
|
|
|
|
##==============================================================================
|
|
## History options
|
|
|
|
HISTFILE="$ZCACHE/history"
|
|
HISTSIZE=1000
|
|
SAVEHIST=1000
|
|
setopt hist_ignore_all_dups
|
|
setopt hist_ignore_space # Commands beginning with a space won't be recorded.
|
|
setopt appendhistory
|
|
|
|
##==============================================================================
|
|
## Misc
|
|
|
|
## Not recommended.
|
|
# setopt completealiases
|
|
|
|
setopt autocd # When only dirname is entered, then auto cd to it.
|
|
|
|
## ???
|
|
# setopt extendedglob nomatch notify
|
|
|
|
## Usually not needed if pc speaker is off.
|
|
unsetopt beep
|
|
|
|
## Turn of ^s so it does not freeze output.
|
|
unsetopt flowcontrol
|
|
|
|
##==============================================================================
|
|
## Directory stack
|
|
|
|
## We use expanded path for DIRSTACKFILE since we need to locate it for the
|
|
## zshcd script.
|
|
DIRSTACKFILE="$HOME/.cache/zsh/dirs"
|
|
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
|
|
dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
|
|
[[ -d $dirstack[1] ]] && cd $dirstack[1]
|
|
fi
|
|
chpwd() {
|
|
print -l $PWD ${(u)dirstack} >$DIRSTACKFILE
|
|
}
|
|
|
|
DIRSTACKSIZE=100
|
|
|
|
setopt autopushd pushdsilent pushdtohome
|
|
setopt pushdignoredups
|
|
|
|
## This reverts the +/- operators.
|
|
setopt pushdminus
|
|
|
|
##==============================================================================
|
|
## Completion
|
|
|
|
## Custom completion
|
|
fpath=(~/.shell.d/completion $fpath)
|
|
|
|
autoload -Uz compinit
|
|
# compinit
|
|
compinit -d "$ZCACHE/compdump"
|
|
|
|
zstyle ':completion:*' menu select
|
|
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
|
|
zstyle ':completion:*:commands' rehash true # New binaries in path get recognized.
|
|
|
|
zstyle ':completion:*' completer _complete _match _approximate ## Allow approximate
|
|
zstyle ':completion:*:match:*' original only
|
|
zstyle ':completion:*:approximate:*' max-errors 1 numeric
|
|
|
|
## Tab completion for PID :D -- Useless ?
|
|
# zstyle ':completion:*:*:kill:*' menu yes select
|
|
# zstyle ':completion:*:kill:*' force-list always
|
|
|
|
## ???
|
|
# zstyle :compinstall filename "$HOME/.zshrc"
|
|
|
|
##==============================================================================
|
|
## TESTING
|
|
|
|
## Remove RPS1 after <enter>
|
|
setopt transient_rprompt
|
|
|
|
## Color vars
|
|
autoload -U colors terminfo
|
|
colors
|
|
|
|
## Zargs powaa
|
|
autoload -U zargs
|
|
|
|
##==============================================================================
|
|
## Prompt
|
|
|
|
autoload -U promptinit
|
|
promptinit
|
|
prompt adam2
|
|
|
|
##==============================================================================
|
|
## fzf (external)
|
|
|
|
if [ -f /usr/share/fzf/key-bindings.zsh ]; then
|
|
. /usr/share/fzf/key-bindings.zsh
|
|
. /usr/share/fzf/completion.zsh
|
|
bindkey '^T' transpose-chars
|
|
bindkey '\e^t' fzf-file-widget
|
|
bindkey '\ec' capitalize-word
|
|
bindkey '\eC' fzf-cd-widget
|
|
|
|
fzf-bcd() {
|
|
setopt localoptions pipefail 2> /dev/null
|
|
cd "${$(pwd | nawk -v RS=/ '/\n/ {exit} {p=p $0 "/"; print p}' | fzf --tac):-.}"
|
|
local ret=$?
|
|
zle reset-prompt
|
|
zle redisplay
|
|
typeset -f zle-line-init >/dev/null && zle zle-line-init
|
|
return $ret
|
|
}
|
|
zle -N fzf-bcd
|
|
bindkey "\e^L" fzf-bcd
|
|
|
|
fzf-cdhist() {
|
|
setopt localoptions pipefail 2> /dev/null
|
|
cd "${$(dirs -lp | fzf):-.}"
|
|
local ret=$?
|
|
zle reset-prompt
|
|
zle redisplay
|
|
typeset -f zle-line-init >/dev/null && zle zle-line-init
|
|
return $ret
|
|
}
|
|
zle -N fzf-cdhist
|
|
bindkey "\er" fzf-cdhist
|
|
fi
|