all repos — archive/dotfiles @ d572253f235621e4575d9328232d76eefce20a0f

Superseded by nixfiles

tag-zsh/config/zsh/zshrc (view raw)

# -*- mode: sh; -*-
source ${ZPLUG_HOME:-~/projects/zplug}/init.zsh

zplug "zsh-users/zsh-completions"
zplug "mafredri/zsh-async", use:async.zsh
zplug "sindresorhus/pure", on:"mafredri/zsh-async", as:plugin, use:pure.zsh
zplug "Tarrasch/zsh-autoenv", as:plugin
zplug "clvv/fasd", hook-build:"PREFIX=$HOME make install"
zplug "alanpearce/zsh-directory-history", at:"dirlog-as-zsh-function", as:command, use:"dirhist"
zplug "alanpearce/zsh-directory-history", at:"dirlog-as-zsh-function", as:plugin
zplug "caarlos0/zsh-open-pr", as:plugin

WORDCHARS=${${WORDCHARS//[-.]}//[\/]}

if [[ ${path[(I)$HOME/bin ]} ]]
then
	path+=($HOME/bin)
fi

ls='\ls'
gnu_ls_options="-v --group-directories-first --color=auto"
gnu_ls_isodate="--time-style=long-iso"
bsd_ls_options="-p"
bsd_ls_isodate="-D '%F %k:%M'"

case $OSTYPE in
	darwin*)
		if [[ -n $commands[gls] ]]
		then
			ls='\gls'
			ls_options=$gnu_ls_options
			ls_isodate=$gnu_ls_isodate
		else
			ls_options=$bsd_ls_options
			ls_isodate=$bsd_ls_isodate
		fi
		;;
	freebsd*)
		ls_options=$bsd_ls_options
		ls_isodate=$bsd_ls_isodate
		;;
	linux-gnu)
		ls_options=$gnu_ls_options
		ls_isodate=$gnu_ls_isodate
		;;
esac
alias l="${ls} ${ls_options} -Bp"
alias l1="${ls} ${ls_options} -1"
alias ls="${ls} ${ls_options} -hF"
alias la="${ls} ${ls_options} -hA"
alias ll="${ls} ${ls_options} ${ls_isodate} -hl"
alias lal="ll -A"
alias lla="lal"
alias llr="ll -t"

bindkey '\e[3~' delete-char

backward-argument () {
	local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\""
	zle backward-word
}

forward-argument () {
	local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\""
	zle forward-word
}

kill-argument () {
	local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\""
	zle backward-argument
	zle kill-word
}

zle -N backward-argument
zle -N forward-argument
zle -N kill-argument
bindkey '\e^b' backward-argument
bindkey '\e^f' forward-argument
bindkey '\e^k' kill-argument

zle -C hist-complete complete-word _generic
zstyle ':completion:hist-complete:*' completer _history
bindkey '\e	' hist-complete

zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}'
zstyle ':completion:*' completer _expand _complete _match

if zplug check Tarrasch/zsh-autoenv
then
	AUTOENV_FILE_ENTER=.envrc
	AUTOENV_HANDLE_LEAVE=0
	AUTOENV_LOOK_UPWARDS=1
fi

if zplug check sindresorhus/pure
then
	PURE_GIT_PULL=0
fi

# Then, source plugins and add commands to $PATH
zplug load

# General configuration
setopt auto_cd 					# Change directories without `cd`

if zplug check zsh-users/zsh-completions
then
	autoload -U compinit && compinit
fi

if zplug check sindresorhus/pure
then
	autoload -Uz promptinit && promptinit
	prompt pure &> /dev/null
fi

if zplug check clvv/fasd
then
	if [[ -n $commands[fasd] ]]
	then
		_FASD_DATA="$HOME/.cache/zsh/fasd-data"
		source =fasd

		fasd_cache="$HOME/.fasd-init-zsh"
		if [ "$(command -v fasd)" -nt "$fasd_cache" -o ! -s "$fasd_cache" ]; then
			fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install >| "$fasd_cache"
		fi
		source "$fasd_cache"
		unset fasd_cache
	else
		echo "no fasd"
	fi
fi

if zplug check alanpearce/zsh-directory-history
then
	unsetopt flow_control 			# Let me use ^S and ^Q
	# bindkey '\e[A' directory-history-search-backward
	# bindkey '\e[B' directory-history-search-forward

	bindkey -M emacs '^R' history-substring-search-up
	bindkey -M emacs '^S' history-substring-search-down
fi