Files
dots/files/shell/.zshrc
2023-10-06 15:30:37 +02:00

71 lines
2.1 KiB
Bash

# ~/.zshrc
#
# ~ M. Thomas
# ============================== Prompt
autoload -Uz vcs_info
autoload -U colors && colors
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
ICON="%(?.%{$fg[green]%}.%{$fg[red]%})󱞩"
DIR="%{$fg[blue]%}%~"
GIT="%{$fg[red]%}\$vcs_info_msg_0_"
HOSTN="%{$fg[yellow]%}%m "
NEWLINE=$'\n'
export PROMPT="${HOSTN}${DIR}${GIT}${NEWLINE}${ICON}%{$reset_color%} "
zstyle ':vcs_info:git:*' formats ' (%b )'
# ============================== Completion
unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
setopt auto_menu # show completion menu on successive tab press
setopt complete_in_word
setopt always_to_end
zstyle ':completion:*' menu select
autoload -Uz compinit
compinit -C
_comp_options+=(globdots)
# Case Insensitive completion
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
## Directory navigation
setopt autocd autopushd
# ============================== History
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 inside tmux
export HISTFILE="$HOME/.zsh_history"
export SAVEHIST=5000
# ============================== Jump Words
bindkey '^[n' forward-word
bindkey '^[p' backward-word
# ============================== Fancy Hacks
# Always use C-z for bg and fg
fancy-ctrl-z () {
if [[ $#BUFFER -eq 0 ]]; then
BUFFER="fg"
zle accept-line
else
zle push-input
zle clear-screen
fi
}
zle -N fancy-ctrl-z
bindkey '^Z' fancy-ctrl-z
# ============================== Source other definitions
[ -f ~/.shellrc.alias ] && source ~/.shellrc.alias
[ -f ~/.shellrc.local ] && source ~/.shellrc.local
if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi