2021-11-04 23:18:36 -04:00
|
|
|
# `.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
|
2021-11-22 09:58:57 -05:00
|
|
|
[ -f $HOME/.local/share/miniplug.zsh ] || curl \
|
2021-11-04 23:18:36 -04:00
|
|
|
-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
|
|
|
|
|
2022-07-04 21:25:22 -04:00
|
|
|
# bindkey -s '^f' '^Ufghq^M' # fghq from alias
|
2022-02-20 18:15:13 -05:00
|
|
|
|
2021-11-04 23:18:36 -04:00
|
|
|
# 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
|
2022-08-17 14:34:53 -04:00
|
|
|
setopt HIST_IGNORE_SPACE # put a space at the front and you won't record history
|
2021-11-04 23:18:36 -04:00
|
|
|
|
|
|
|
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
|
2021-12-09 10:32:53 -05:00
|
|
|
alias czh="echo 'Fully clearing history, then exiting...' && cat /dev/null > ${HISTFILE} && history -p && exit"
|
2021-11-04 23:18:36 -04:00
|
|
|
|
|
|
|
# Completion
|
|
|
|
_comp_options+=(globdots) # include hidden files
|
|
|
|
|
2021-12-11 22:24:06 -05:00
|
|
|
# reload the zsh session. Changed from OMZ:plugins/zsh_reload
|
2021-11-04 23:18:36 -04:00
|
|
|
zreload() {
|
2021-12-11 22:24:06 -05:00
|
|
|
# Use $SHELL if available; remove leading dash if login shell
|
|
|
|
[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
|
|
|
|
}
|
|
|
|
|
2021-12-27 10:51:55 -05:00
|
|
|
# w/ SSH
|
|
|
|
if [[ "$HOST" == core.envs.net ]]; then
|
|
|
|
export GPG_TTY=$(tty)
|
2021-12-11 22:24:06 -05:00
|
|
|
fi
|
|
|
|
|
2022-06-22 20:02:42 -04:00
|
|
|
# tycho (which is a laptop)
|
2022-07-05 22:08:42 -04:00
|
|
|
#if [[ "$HOST" == tycho && -z "$DISPLAY" ]]; then
|
|
|
|
# export GPG_TTY=$(tty)
|
|
|
|
#fi
|
|
|
|
|
|
|
|
gpgtemp() {
|
2022-06-22 20:02:42 -04:00
|
|
|
export GPG_TTY=$(tty)
|
2022-07-05 22:08:42 -04:00
|
|
|
echo "remember to run gpgyeet once done..."
|
|
|
|
}
|
2022-06-22 20:02:42 -04:00
|
|
|
|
2021-12-27 21:18:49 -05:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2022-08-16 20:49:42 -04:00
|
|
|
# GPG: invalidate cache
|
2021-12-27 22:04:55 -05:00
|
|
|
gpgyeet() {
|
|
|
|
echo RELOADAGENT | gpg-connect-agent
|
2022-07-05 22:08:42 -04:00
|
|
|
unset GPG_TTY
|
2021-12-27 22:04:55 -05:00
|
|
|
}
|
|
|
|
|
2021-12-27 22:42:59 -05:00
|
|
|
# emacs magit
|
|
|
|
magit() {
|
2023-10-02 11:23:32 -04:00
|
|
|
emacs --eval "(progn (magit-status) (delete-other-windows))" "$@"
|
2022-02-21 10:05:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# eye candy: auto onefetch (consider if this is really needed lol)
|
|
|
|
# https://www.reddit.com/r/unixporn/comments/sxa02o/oc_neofetch_for_git_repositories/
|
2021-12-27 22:42:59 -05:00
|
|
|
|
2021-11-04 23:18:36 -04:00
|
|
|
# PLUGINS!
|
|
|
|
# `miniplug update`
|
|
|
|
|
|
|
|
miniplug plugin 'zsh-users/zsh-syntax-highlighting'
|
|
|
|
miniplug plugin 'hlissner/zsh-autopair'
|
|
|
|
|
|
|
|
miniplug theme 'tjquillan/pastel'
|
|
|
|
|
|
|
|
miniplug load
|
|
|
|
|
2022-07-06 13:52:32 -04:00
|
|
|
export SD_ROOT="$HOME/.dotfiles/.sd"
|
|
|
|
export SD_CAT=bat
|
|
|
|
|
2021-11-04 23:18:36 -04:00
|
|
|
# auto cd must be set later
|
|
|
|
setopt AUTO_CD
|
|
|
|
|
|
|
|
# Hooks
|
|
|
|
eval "$(direnv hook zsh)"
|
2022-01-24 11:20:35 -05:00
|
|
|
eval "$(zoxide init zsh)"
|
2023-10-02 11:23:32 -04:00
|
|
|
|
|
|
|
PATH="/Users/earne/perl5/bin${PATH:+:${PATH}}"; export PATH;
|
|
|
|
PERL5LIB="/Users/earne/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
|
|
|
|
PERL_LOCAL_LIB_ROOT="/Users/earne/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
|
|
|
|
PERL_MB_OPT="--install_base \"/Users/earne/perl5\""; export PERL_MB_OPT;
|
|
|
|
PERL_MM_OPT="INSTALL_BASE=/Users/earne/perl5"; export PERL_MM_OPT;
|