140 lines
3.9 KiB
Bash
140 lines
3.9 KiB
Bash
# `.zshrc' is sourced in interactive shells. It should contain
|
|
# commands to set up aliases, functions, options, key bindings, etc.
|
|
|
|
# If not running interactively, don't do anything
|
|
[[ $- != *i* ]] && return
|
|
|
|
autoload -U colors && colors
|
|
autoload -Uz promptinit && promptinit
|
|
autoload -U compinit && compinit
|
|
|
|
# Init plugin handling
|
|
[ -f $HOME/.local/share/miniplug.zsh ] || curl \
|
|
-sL --create-dirs \
|
|
https://git.sr.ht/~yerinalexey/miniplug/blob/master/miniplug.zsh \
|
|
-o $HOME/.local/share/miniplug.zsh
|
|
source "$HOME/.local/share/miniplug.zsh"
|
|
|
|
# Use emacs keybindings even if our EDITOR is set to vi
|
|
bindkey -e
|
|
|
|
bindkey "^[[1;5C" forward-word
|
|
bindkey "^[[1;5D" backward-word
|
|
bindkey -s '^L' '^Uclear^M' # clear using alias
|
|
|
|
autoload edit-command-line; zle -N edit-command-line
|
|
bindkey '^k' edit-command-line
|
|
|
|
bindkey -s '^f' '^Ufghq^M' # fghq from alias
|
|
|
|
# History
|
|
HISTORY_IGNORE="(ls|cd|pwd|exit|sudo reboot|history|cd -|cd ..)"
|
|
HISTFILE="$HOME/.zsh_history"
|
|
HISTSIZE=99999
|
|
SAVEHIST=90000
|
|
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 # Don't add duplicate entries
|
|
setopt hist_ignore_space # ignore commands that start with space
|
|
setopt hist_verify # show command with history expansion to user before running it
|
|
setopt inc_append_history # add commands to HISTFILE in order of execution
|
|
setopt share_history # share command history data
|
|
setopt hist_find_no_dups # don't display duplicates in reverse search
|
|
setopt hist_reduce_blanks # remove superfluous blanks
|
|
|
|
setopt interactivecomments # Comments in the interactive shell
|
|
setopt auto_continue # Send CONT signal automatically when disowning jobs
|
|
# pushd
|
|
setopt pushd_ignore_dups
|
|
export DIRSTACKSIZE=20
|
|
setopt auto_pushd
|
|
|
|
# Load aliases
|
|
source "$HOME/.config/shell_common/aliases.sh"
|
|
|
|
# zsh-specific aliases
|
|
# clear zsh history: Adapted from Novimatrem: https://gitlab.com/Novimatrem/clear-bash-history
|
|
alias czh="echo 'Fully clearing history, then exiting...' && cat /dev/null > ${HISTFILE} && history -p && exit"
|
|
|
|
# Completion
|
|
_comp_options+=(globdots) # include hidden files
|
|
|
|
# reload the zsh session. Changed from OMZ:plugins/zsh_reload
|
|
zreload() {
|
|
# Use $SHELL if available; remove leading dash if login shell
|
|
[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
|
|
}
|
|
|
|
# w/ SSH
|
|
if [[ "$HOST" == core.envs.net ]]; then
|
|
export GPG_TTY=$(tty)
|
|
fi
|
|
|
|
if [[ "$HOST" == tycho && -z "$DISPLAY" ]]; then
|
|
export GPG_TTY=$(tty)
|
|
fi
|
|
|
|
# pash configuration
|
|
export PASH_KEYID=BF66E5C8A1416E2A857C774CA343F43342EB6E2A
|
|
pash() {
|
|
case $1 in
|
|
g*) # git, not using atm
|
|
cd "${PASH_DIR:=${XDG_DATA_HOME:=$HOME/.local/share}/pash}"
|
|
shift
|
|
git "$@"
|
|
;;
|
|
sync) # uses rsync, will overwrite to match local
|
|
cd "${PASH_DIR:=${XDG_DATA_HOME:=$HOME/.local/share}/pash}"
|
|
shift; send_host="$1"; shift
|
|
[ -z "$send_host" ] && echo "No destination provided" || \
|
|
rsync -ravz --delete . \
|
|
"${send_host}:${PASH_DIR:=${XDG_DATA_HOME:=$HOME/.local/share}/pash}" "$@"
|
|
;;
|
|
*)
|
|
command pash "$@"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# GPG: invalidate acahe
|
|
gpgyeet() {
|
|
echo RELOADAGENT | gpg-connect-agent
|
|
}
|
|
|
|
# emacs magit
|
|
magit() {
|
|
emacs --eval "(progn (magit-status) (delete-other-windows))"
|
|
}
|
|
|
|
# eye candy: auto onefetch (consider if this is really needed lol)
|
|
# https://www.reddit.com/r/unixporn/comments/sxa02o/oc_neofetch_for_git_repositories/
|
|
LAST_REPO=""
|
|
cd(){
|
|
builtin cd "$@"
|
|
git rev-parse 2>/dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
if [ "$LAST_REPO" != $(basename $(git rev-parse --show-toplevel)) ]; then
|
|
onefetch
|
|
LAST_REPO=$(basename $(git rev-parse --show-toplevel))
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# PLUGINS!
|
|
# `miniplug update`
|
|
|
|
miniplug plugin 'zsh-users/zsh-syntax-highlighting'
|
|
miniplug plugin 'hlissner/zsh-autopair'
|
|
|
|
miniplug theme 'tjquillan/pastel'
|
|
|
|
miniplug load
|
|
|
|
# auto cd must be set later
|
|
setopt AUTO_CD
|
|
|
|
# Hooks
|
|
eval "$(direnv hook zsh)"
|
|
eval "$(zoxide init zsh)"
|