notes/zshrc.txt

136 lines
4.8 KiB
Text

# ~/.zshrc
#
# to change default shell, use chsh -s $(which zsh)
#
# create custom env variables:
#
export cproj="/home/brian/Documents/Code/source_code_to_study/sandbox/msh"
# custom BROWSER env for ddgr:
export BROWSER=links
export TUIR_BROWSER=librewolf
export EDITOR=nvim
# Colorizes man pages
export LESS_TERMCAP_mb=$'\e[1;34m'
export LESS_TERMCAP_md=$'\e[1;34m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;33m'
# Formats history command with dates/times
export HISTTIMEFORMAT="%d/%m/%y %T "
# Configure thefuck
eval "$(thefuck --alias)"
# Change with care:
export PATH="$PATH:$GOPATH/bin:/home/brian/scripts:/home/brian/.local/bin:/home/brian/.local/share/nvim/lsp_servers"
# Configure grep output colors
export GREP_COLORS='ms=01;34'
# Enable fuzzy file finder
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Don't show completion until at least 1 character has been typed
zstyle ':autocomplete:*' min-input 1
# autoload -U compinit; compinit
#
# Plugins
source ~/.zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
# icons-in-terminal Integration
# source ~/.local/share/icons-in-terminal/icons_bash.sh
# Colors
autoload -Uz colors && colors
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# git info/styling for prompt
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr '%B%F{yellow} +'
zstyle ':vcs_info:*' stagedstr '%B%F{green} ✓'
zstyle ':vcs_info:git:*' formats '%b%u%c'
zstyle ':vcs_info:git:*' actionformats '%b|%a%u%c'
# Set up the prompt (with git branch name)
setopt PROMPT_SUBST
# some useful options (man zshoptions)
setopt autocd extendedglob nomatch menucomplete
setopt interactive_comments
stty stop undef # Disable ctrl-s to freeze terminal
zle_highlight=('paste:none') # pasting text using ctrl+shift+v doesn't highlight
# beeping is annoying
unsetopt BEEP
# PROMPT='[%n@%m %1~]%F{green}(${vcs_info_msg_0_})%F{white}$ '
PROMPT='%B%F{blue}[%n@%M %B%F{white}'%1~'%B%F{blue}]$ %B%F{white}${vcs_info_msg_0_}%B%F{blue}
└─>%B%F{white} '
# PROMPT='%B%F{green}[%n@%M %B%F{white}'%1~'%B%F{green}]$ %B%F{white}${vcs_info_msg_0_}%B%F{green}
# └─>%B%F{white} '
# function erase_history { local HISTSIZE=0; }
# erase_history && hash -r
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -g -A key
key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
key[Insert]="${terminfo[kich1]}"
key[Backspace]="${terminfo[kbs]}"
key[Delete]="${terminfo[kdch1]}"
key[Up]="${terminfo[kcuu1]}"
key[Down]="${terminfo[kcud1]}"
key[Left]="${terminfo[kcub1]}"
key[Right]="${terminfo[kcuf1]}"
key[PageUp]="${terminfo[kpp]}"
key[PageDown]="${terminfo[knp]}"
key[Shift-Tab]="${terminfo[kcbt]}"
# setup key accordingly
[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode
[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char
[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history
[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
autoload -Uz add-zle-hook-widget
function zle_application_mode_start { echoti smkx }
function zle_application_mode_stop { echoti rmkx }
add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
fi
# Set up vim mode
bindkey -v
# Kitty Shell Integration
# if test -n "$KITTY_INSTALLATION_DIR"; then
# export KITTY_SHELL_INTEGRATION="enabled"
# autoload -Uz -- "$KITTY_INSTALLATION_DIR"/shell-integration/zsh/kitty-integration
# kitty-integration
# unfunction kitty-integration
# fi
alias home="xclear && cd /home/brian && clear && history -p && hash -r"
source ~/.aliases
# Plugins (that need to be at the end of the zshrc script)
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh