dotfiles/zshrc

138 lines
4.7 KiB
Bash
Raw Normal View History

2022-05-19 13:56:07 +00:00
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
2022-05-19 13:56:07 +00:00
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
2022-05-20 18:55:19 +00:00
# zcomet install
if [[ ! -f ${ZDOTDIR:-${HOME}}/.zcomet/bin/zcomet.zsh ]]; then
command git clone https://github.com/agkozak/zcomet.git ${ZDOTDIR:-${HOME}}/.zcomet/bin
fi
# zcomit + shell line activation
source ${ZDOTDIR:-${HOME}}/.zcomet/bin/zcomet.zsh
zcomet load romkatv/powerlevel10k
2022-05-19 13:56:07 +00:00
2022-05-20 18:55:19 +00:00
# misc plugins
zcomet load zsh-users/zsh-syntax-highlighting
zcomet load ytakahashi/igit
2022-05-20 03:04:29 +00:00
if [[ -n "${TMUX}" ]]; then
2022-05-20 18:55:19 +00:00
zcomet load mbenford/zsh-tmux-auto-title
2022-05-20 03:04:29 +00:00
fi
2022-05-19 13:56:07 +00:00
2022-05-20 18:55:19 +00:00
# fzf
zcomet load junegunn/fzf shell completion.zsh key-bindings.zsh
(( ${+commands[fzf]} )) || ~[fzf]/install --bin
zcomet load Aloxaf/fzf-tab
#zcomet load ddnexus/fm
# history
zcomet load larkery/zsh-histdb
zcomet load m42e/zsh-histdb-skim
2022-05-19 13:56:07 +00:00
2022-05-20 18:55:19 +00:00
# Run compinit and compile its cache
zcomet compinit
2022-05-19 13:56:07 +00:00
# zsh options
autoload run-help
setopt auto_pushd
setopt clobber
setopt complete_aliases
setopt correct
#setopt correct_all
setopt extended_glob
setopt extended_history
setopt hash_list_all
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt no_beep
setopt no_hist_allow_clobber
setopt no_rm_star_silent
setopt notify
setopt prompt_subst
setopt pushd_ignore_dups
setopt pushd_silent
setopt pushd_to_home
setopt rm_star_wait
export SAVEHIST=1000000
export HISTSIZE=1000000
export HISTFILE=~/.zsh_history
setopt append_history
setopt share_history
# zsh plugin options
2022-05-20 03:04:29 +00:00
if [[ -n "${TMUX}" ]]; then
ZSH_TMUX_AUTO_TITLE_SHORT=true
ZSH_TMUX_AUTO_TITLE_IDLE_TEXT="%last"
fi
2022-05-19 13:56:07 +00:00
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
# misc / general
export EDITOR="nano"
export PAGER="most"
2022-05-19 13:56:07 +00:00
export PATH=~/.local/bin:${PATH}
# asdf
2022-05-19 13:56:07 +00:00
. $HOME/.asdf/asdf.sh
# aliases (before interactive, just in case)
2022-05-19 14:10:00 +00:00
alias ls="exa"
2022-05-19 13:56:07 +00:00
# dont allow mosh prediction (override in zshrc.local)
export MOSH_PREDICTION_DISPLAY="never"
2022-05-19 13:56:07 +00:00
# local overrides
test -f ~/.zshrc.local && source ~/.zshrc.local
# dont do anything more if non interactive
if [[ ! -o interactive ]]; then
return
fi
# setup mode/status line for zsh
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# ensure histdb gets ctrl-r for history
if grep -q "Android" <<< `uname -a`; then
source ~/.zplug/repos/larkery/zsh-histdb/histdb-interactive.zsh
bindkey '^R' _histdb-isearch
else
bindkey '^R' histdb-skim-widget
fi
2022-05-19 13:56:07 +00:00
# Fix home/end/del silly
if [[ "$TERM" != emacs ]]; then
[[ -z "$terminfo[kdch1]" ]] || bindkey -M emacs "$terminfo[kdch1]" delete-char
[[ -z "$terminfo[khome]" ]] || bindkey -M emacs "$terminfo[khome]" beginning-of-line
[[ -z "$terminfo[kend]" ]] || bindkey -M emacs "$terminfo[kend]" end-of-line
[[ -z "$terminfo[kich1]" ]] || bindkey -M emacs "$terminfo[kich1]" overwrite-mode
[[ -z "$terminfo[kdch1]" ]] || bindkey -M vicmd "$terminfo[kdch1]" vi-delete-char
[[ -z "$terminfo[khome]" ]] || bindkey -M vicmd "$terminfo[khome]" vi-beginning-of-line
[[ -z "$terminfo[kend]" ]] || bindkey -M vicmd "$terminfo[kend]" vi-end-of-line
[[ -z "$terminfo[kich1]" ]] || bindkey -M vicmd "$terminfo[kich1]" overwrite-mode
[[ -z "$terminfo[cuu1]" ]] || bindkey -M viins "$terminfo[cuu1]" vi-up-line-or-history
[[ -z "$terminfo[cuf1]" ]] || bindkey -M viins "$terminfo[cuf1]" vi-forward-char
[[ -z "$terminfo[kcuu1]" ]] || bindkey -M viins "$terminfo[kcuu1]" vi-up-line-or-history
[[ -z "$terminfo[kcud1]" ]] || bindkey -M viins "$terminfo[kcud1]" vi-down-line-or-history
[[ -z "$terminfo[kcuf1]" ]] || bindkey -M viins "$terminfo[kcuf1]" vi-forward-char
[[ -z "$terminfo[kcub1]" ]] || bindkey -M viins "$terminfo[kcub1]" vi-backward-char
# ncurses fogyatekos
[[ "$terminfo[kcuu1]" == "^[O"* ]] && bindkey -M viins "${terminfo[kcuu1]/O/[}" vi-up-line-or-history
[[ "$terminfo[kcud1]" == "^[O"* ]] && bindkey -M viins "${terminfo[kcud1]/O/[}" vi-down-line-or-history
[[ "$terminfo[kcuf1]" == "^[O"* ]] && bindkey -M viins "${terminfo[kcuf1]/O/[}" vi-forward-char
[[ "$terminfo[kcub1]" == "^[O"* ]] && bindkey -M viins "${terminfo[kcub1]/O/[}" vi-backward-char
[[ "$terminfo[khome]" == "^[O"* ]] && bindkey -M viins "${terminfo[khome]/O/[}" beginning-of-line
[[ "$terminfo[kend]" == "^[O"* ]] && bindkey -M viins "${terminfo[kend]/O/[}" end-of-line
[[ "$terminfo[khome]" == "^[O"* ]] && bindkey -M emacs "${terminfo[khome]/O/[}" beginning-of-line
[[ "$terminfo[kend]" == "^[O"* ]] && bindkey -M emacs "${terminfo[kend]/O/[}" end-of-line
fi