zsh/zshrc

112 lines
3.3 KiB
Bash
Raw Normal View History

2020-04-01 16:39:01 +00:00
# if using zgen must do 'zgen reset' after any changes to this file
2020-02-27 14:46:48 +00:00
emulate sh
source "${HOME}/.profile"
emulate zsh
autoload -Uz compinit
autoload -Uz colors
typeset -i updated_at=$(date +'%j' -r ~/.zcompdump 2>/dev/null || stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)
if [ $(date +'%j') != $updated_at ]; then
compinit -i
else
compinit -C -i
fi
2020-04-01 16:39:01 +00:00
# https://wiki.archlinux.org/index.php/Zsh#xterm_title
autoload -Uz add-zsh-hook
function xterm_title_precmd () {
print -Pn -- '\e]2;%n@%m %~\a'
[[ "$TERM" == 'screen'* ]] && print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-}\e\\'
}
function xterm_title_preexec () {
print -Pn -- '\e]2;%n@%m %~ %# ' && print -n -- "${(q)1}\a"
[[ "$TERM" == 'screen'* ]] && { print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-} %# ' && print -n -- "${(q)1}\e\\"; }
}
if [[ "$TERM" == (alacritty*|gnome*|konsole*|putty*|rxvt*|screen*|tmux*|xterm*) ]]; then
add-zsh-hook -Uz precmd xterm_title_precmd
add-zsh-hook -Uz preexec xterm_title_preexec
fi
2020-02-27 14:46:48 +00:00
# zgen
# https://github.com/tarjoilija/zgen
# after changes must do:
# zgen reset
# to remove static init script
source "${HOME}/.config/zsh/zgen/zgen.zsh"
# if the init script doesn't exist
if ! zgen saved; then
# specify plugins here
zgen load zdharma/fast-syntax-highlighting
zgen load zsh-users/zsh-autosuggestions
zgen load zsh-users/zsh-history-substring-search
zgen load zsh-users/zsh-completions
zgen load wbingli/zsh-wakatime
zgen load supercrabtree/k
# generate the init script from plugins above
zgen save
fi
# HISTFILE=~/.histfile
# HISTSIZE=10000
# SAVEHIST=$HISTSIZE
setopt hist_ignore_all_dups # remove older duplicate entries from history
setopt hist_reduce_blanks # remove superfluous blanks from history items
setopt inc_append_history # save history entries as soon as they are entered
setopt share_history # share history between different instances of the shell
setopt auto_cd # cd by typing directory name if it's not a command
setopt correct_all # autocorrect commands
setopt auto_list # automatically list choices on ambiguous completion
setopt auto_menu # automatically use menu completion
setopt always_to_end # move cursor to end if word had one match
unsetopt BEEP
zstyle ':completion:*' menu select # select completions with arrow keys
zstyle ':completion:*' group-name '' # group results by category
zstyle ':completion:::::' completer _expand _complete _ignored _approximate # enable approximate matches
2020-07-13 20:31:30 +00:00
# use emacs style keymaps (ctrl+a, ctrl+e, etc)
bindkey -e
2020-02-27 14:46:48 +00:00
# The following line was added by compinstall
zstyle :compinstall filename '/home/ray/.zshrc'
zmodload -i zsh/complist
zstyle ':completion:*' menu select
zmodload zsh/complist
# use the vi navigation keys in menu completion
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
# zsh-history-subsrting-search settings
HISTORY_SUBSTRING_SEARCH_FUZZY=true
2020-07-13 11:36:27 +00:00
bindkey '^p' history-substring-search-up
bindkey '^n' history-substring-search-down
2020-02-27 14:46:48 +00:00
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=239'
#zsh-autosuggestion settings
bindkey '^f' autosuggest-accept
alias todone='task_done'
2020-05-11 13:36:07 +00:00
# remove duplicate PATH entries
# https://til.hashrocket.com/posts/7evpdebn7g-remove-duplicates-in-zsh-path
typeset -aU path
2020-07-13 20:15:46 +00:00
eval "$(starship init zsh)"