dotfiles/zsh/.zshrc

82 lines
2.2 KiB
Bash

# If not running interactively, don't do anything
[ -z "$PS1" ] && return
export HISTFILE=$ZDOTDIR/.zsh_history
export HISTSIZE=9998
export SAVEHIST=10000
# terminal colors
export COLORTERM=24bit
# Setting some opts
# setopt correct_all
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
setopt extended_history # record timestamp of command in HISTFILE
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
setopt share_history # share command history data
setopt long_list_jobs
setopt interactivecomments
# Initialize the completion system
# fpath=(~/config/zsh/.zsh $fpath)
autoload -U compinit ; compinit
## Vi keybindings for the shell ##
bindkey -v
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line
## History navigation by search pattern
autoload history-search-end
zle -N history-beginning-search-backward-end \
history-search-end
zle -N history-beginning-search-forward-end \
history-search-end
bindkey '^[[A' history-beginning-search-backward-end
bindkey '^[[B' history-beginning-search-forward-end
## Aliases
source ~/.config/zsh/aliases.zsh
source ~/.config/zsh/completion.zsh
source ~/.config/zsh/termsupport.zsh
source ~/.config/zsh/theme-and-appearance.zsh
# Starship
eval "$(starship init zsh)"
# Block and beam cursors for 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[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