dotfiles/.zshrc

107 lines
2.8 KiB
Bash

# The following lines were added by compinstall
zstyle ':completion:*' completer _complete _ignored
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' '+m:{[:lower:]}={[:upper:]}' '+m:{[:lower:][:upper:]}={[:upper:][:lower:]}'
zstyle :compinstall filename '/home/r1k/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=100000
setopt notify
unsetopt beep
bindkey -v
# End of lines configured by zsh-newuser-install
#
# Do not write a duplicate event to the history file.
setopt HIST_SAVE_NO_DUPS
# Find and set branch name var if in git repository.
function git_branch_name()
{
branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
if [[ $branch == "" ]];
then
:
else
echo '- ('$branch')'
fi
}
# Enable substitution in the prompt.
setopt prompt_subst
# Config for prompt. PS1 synonym.
prompt='%d/ $(git_branch_name) > '
source ~/.bash_aliases
export EDITOR=nvim
export PATH=/home/rick/.ghcup/bin/:$PATH:/home/rick/.emacs.d/bin/:/home/rick/jrnl/ecpd/7tools/:$HOME/.config/nvim/plugged/vim-superman/bin
# keybinds
bindkey ";5C" forward-word
bindkey ";5D" backward-word
# zsh syntax highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# zsh autocompletions
#source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
# zsh history substring search
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
# open editor
autoload -z edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line
# from https://dev.to/phantas0s/understanding-and-configuring-zsh-3jnd
export KEYTIMEOUT=1
###
# change cursor in vim mode
cursor_mode() {
# See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
cursor_block='\e[2 q'
cursor_beam='\e[4 q'
# cursor_beam='\e[6 q'
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne $cursor_block
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne $cursor_beam
fi
}
zle-line-init() {
echo -ne $cursor_beam
}
zle -N zle-keymap-select
zle -N zle-line-init
}
cursor_mode
###
# open man and info from neovim
compdef vman="man"
## sdcv dictionary
export STARDICT_DATA_DIR=/home/rick/.sdcv