2021-04-08 19:59:58 +02:00
|
|
|
# vim:ft=zsh ts=2 sw=2 sts=2
|
2021-07-16 21:39:46 +02:00
|
|
|
export LANG=en_US.UTF-8
|
2021-04-12 09:58:36 +02:00
|
|
|
|
2020-12-03 20:24:31 +01:00
|
|
|
# theme-related variables
|
2020-12-07 17:19:28 +01:00
|
|
|
export ZSH_CUSTOM="$DOTFILES"
|
2020-02-27 18:19:52 +01:00
|
|
|
export ZSH_THEME="brethil"
|
2020-12-03 20:24:31 +01:00
|
|
|
export DISABLE_UNTRACKED_FILES_DIRTY=true
|
|
|
|
export VIRTUAL_ENV_DISABLE_PROMPT=true
|
2020-02-27 18:19:52 +01:00
|
|
|
|
2022-12-18 13:36:07 +01:00
|
|
|
export PATH=$PATH:$HOME/bin
|
|
|
|
|
2024-04-06 21:24:30 +02:00
|
|
|
if [[ -d "$HOME/.cache/antibody" ]]; then
|
|
|
|
# antibody migration cleanup
|
|
|
|
rm -rf $HOME/.cache/antibody
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d $DOTFILES/antidote ]]; then
|
|
|
|
git clone https://github.com/mattmc3/antidote.git ${DOTFILES}/antidote
|
|
|
|
fi
|
|
|
|
|
|
|
|
export ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
|
2024-04-17 16:01:39 +02:00
|
|
|
[[ -d $ZSH_CACHE_DIR ]] || mkdir -p $ZSH_CACHE_DIR/completions
|
2024-04-06 21:24:30 +02:00
|
|
|
|
|
|
|
# Lazy-load antidote from its functions directory.
|
|
|
|
fpath=($DOTFILES/antidote/functions/ $fpath)
|
|
|
|
autoload -Uz antidote
|
|
|
|
|
|
|
|
autoload -Uz compinit && compinit
|
|
|
|
autoload -Uz bashcompinit && bashcompinit
|
|
|
|
|
|
|
|
|
|
|
|
# Lazy-load antidote and generate the static load file only when needed # TODO: look into deferred loading with zsh-defer
|
|
|
|
zsh_plugins="$DOTFILES/zsh_plugins"
|
|
|
|
if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then
|
|
|
|
(
|
|
|
|
source $DOTFILES/antidote/antidote.zsh
|
|
|
|
|
|
|
|
echo "ZSH=$(antidote path ohmyzsh/ohmyzsh)" >${zsh_plugins}.zsh
|
|
|
|
|
|
|
|
antidote bundle <${zsh_plugins}.txt >>${zsh_plugins}.zsh
|
|
|
|
|
2024-04-22 09:47:24 +02:00
|
|
|
if (( $+commands[systemctl] )); then
|
2024-04-06 21:24:30 +02:00
|
|
|
antidote bundle robbyrussell/oh-my-zsh path:plugins/systemd >>${zsh_plugins}.zsh
|
|
|
|
fi
|
2024-04-22 09:47:24 +02:00
|
|
|
if (( $+commands[pacman] )); then
|
2024-04-06 21:24:30 +02:00
|
|
|
antidote bundle robbyrussell/oh-my-zsh path:plugins/archlinux >>${zsh_plugins}.zsh
|
2024-04-22 09:47:24 +02:00
|
|
|
elif (( $+commands[apt-get] )); then
|
2024-04-06 21:24:30 +02:00
|
|
|
antidote bundle robbyrussell/oh-my-zsh path:plugins/debian >>${zsh_plugins}.zsh
|
|
|
|
fi
|
|
|
|
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
|
|
|
source ${zsh_plugins}.zsh
|
|
|
|
source "$DOTFILES/themes/brethil.zsh-theme"
|
|
|
|
|
2021-04-11 13:09:47 +02:00
|
|
|
|
2022-08-12 15:45:38 +02:00
|
|
|
# Setup completion style
|
2024-04-10 14:44:17 +02:00
|
|
|
source $DOTFILES/extras/completion_style.zsh
|
|
|
|
source $DOTFILES/extras/colors.zsh
|
2022-11-26 00:52:01 +01:00
|
|
|
source $DOTFILES/extras/fzf-tab-config.zsh
|
2022-08-12 15:45:38 +02:00
|
|
|
|
2024-04-22 09:47:24 +02:00
|
|
|
if (( $+commands[fd] )); then
|
2023-09-14 22:45:24 +02:00
|
|
|
export FZF_CTRL_T_COMMAND='fd'
|
|
|
|
else
|
|
|
|
export FZF_CTRL_T_COMMAND='find'
|
|
|
|
fi
|
|
|
|
export FZF_CTRL_T_OPTS=" --preview-window=right,60% --preview \"bash -c 'if [[ -d \"{}\" ]]; then tree -C \"{}\"; else bat --style=plain --color=always \"{}\"; fi'\" --bind 'ctrl-/:change-preview-window(right,70%|down,40%,border-horizontal|hidden|right)'"
|
|
|
|
|
2023-12-21 16:11:23 +01:00
|
|
|
ZSH_HIGHLIGHT_STYLES[comment]='fg=white,bg=gray,bold'
|
2022-03-26 11:30:16 +01:00
|
|
|
|
2020-02-14 16:37:49 +01:00
|
|
|
# Enable zsh autocorrection
|
|
|
|
setopt CORRECT_ALL
|
|
|
|
|
2020-03-13 21:33:14 +01:00
|
|
|
# share history across multiple zsh sessions
|
|
|
|
setopt SHARE_HISTORY
|
|
|
|
# append to history
|
|
|
|
setopt APPEND_HISTORY
|
|
|
|
|
|
|
|
# adds commands as they are typed, not at shell exit
|
|
|
|
setopt INC_APPEND_HISTORY
|
|
|
|
|
|
|
|
# Execute commands without verifying after prompt substitution (!!, !$, etc)
|
|
|
|
setopt NO_HIST_VERIFY
|
|
|
|
|
2021-12-27 12:55:06 +01:00
|
|
|
# Silence completion beeps
|
|
|
|
unsetopt LIST_BEEP
|
|
|
|
|
|
|
|
|
2019-12-07 22:28:16 +01:00
|
|
|
## Misc environment variables
|
2020-02-14 16:37:43 +01:00
|
|
|
|
2017-07-17 02:00:15 +02:00
|
|
|
# https://www.xkcd.com/378/
|
2024-04-06 21:24:30 +02:00
|
|
|
export EDITOR="vim" # if antibody_plugins.txt includes robbyrussell/oh-my-zsh path:plugins/vi-mode, this also sets `bindkey -v` # FIXME
|
2021-01-15 01:34:10 +01:00
|
|
|
export VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true # refresh prompt on every mode change
|
2020-04-06 19:45:22 +02:00
|
|
|
# Fix delete (delete! not backspace) key
|
|
|
|
bindkey -a '^[[3~' delete-char
|
|
|
|
|
2021-12-08 23:53:09 +01:00
|
|
|
export KEYTIMEOUT=50 # reduce the transition time between vim modes to 0.1s
|
|
|
|
# bindkey -M vicmd 'V' edit-command-line # this remaps `vv` to `V` (but overrides `visual-mode`) # add this if the keytimeout is too slow
|
2020-02-14 16:37:42 +01:00
|
|
|
|
2022-02-07 20:49:58 +01:00
|
|
|
if ! grep -q "set editing-mode vi" $HOME/.inputrc &> /dev/null; then
|
|
|
|
echo "set editing-mode vi" >> ~/.inputrc && echo "Warning: set up editing-mode ~/.inputrc"
|
|
|
|
fi
|
|
|
|
|
2021-05-19 10:30:10 +02:00
|
|
|
export HISTSIZE=10000000
|
2023-09-14 22:46:32 +02:00
|
|
|
export SAVEHIST=10000000
|
2020-03-09 17:54:02 +01:00
|
|
|
|
2022-01-24 09:57:29 +01:00
|
|
|
|
|
|
|
# zsh-autosuggestions config
|
|
|
|
export ZSH_AUTOSUGGEST_STRATEGY=(history completion)
|
2023-12-21 16:11:23 +01:00
|
|
|
export ZSH_AUTOSUGGEST_COMPLETION_IGNORE='* \#*' # prevent completion for comments
|
2022-01-24 09:57:29 +01:00
|
|
|
|
2020-12-04 02:56:45 +01:00
|
|
|
# less options
|
2021-04-08 20:02:37 +02:00
|
|
|
export LESS='-xRF-j12' # -j12: displays 12 lines before search results with / and ?
|
2024-04-22 09:47:24 +02:00
|
|
|
if (( $+commands[bat] || $+commands[batcat] )); then
|
|
|
|
if (( $+commands[bat] )); then cmd=bat else cmd=batcat fi
|
2024-03-08 12:59:28 +01:00
|
|
|
|
|
|
|
alias cat=$cmd
|
|
|
|
export PAGER=$cmd
|
|
|
|
export BAT_PAGER="less $LESS"
|
|
|
|
|
2023-09-14 22:42:04 +02:00
|
|
|
if [[ -n $THEME_PREFER_LIGHT ]]; then
|
|
|
|
export BAT_THEME="gruvbox-light"
|
|
|
|
else
|
|
|
|
export BAT_THEME="gruvbox-dark"
|
|
|
|
fi
|
2023-09-11 15:47:22 +02:00
|
|
|
|
|
|
|
## this breaks symlink testing with [ -h ], best not to activate it
|
|
|
|
# alias -g -- -h='-h 2>&1 | bat --language=help --style=plain'
|
2024-03-08 12:59:28 +01:00
|
|
|
alias bathelp="$cmd --language=help --style=plain"
|
2023-09-11 15:47:22 +02:00
|
|
|
alias -g -- --help='--help 2>&1 | bathelp '
|
2019-12-07 22:28:16 +01:00
|
|
|
fi
|
2020-02-14 16:37:47 +01:00
|
|
|
|
2020-02-14 16:37:44 +01:00
|
|
|
if [[ $SSH_CLIENT ]]; then
|
|
|
|
export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
|
|
|
|
fi
|
2020-02-14 16:37:43 +01:00
|
|
|
|
2023-09-14 22:57:38 +02:00
|
|
|
# Automatically enable/disable virtualenv on chdir/step
|
|
|
|
export DOTFILES_AUTOSWITCH_VIRTUALENV=1
|
|
|
|
|
2019-12-07 22:32:14 +01:00
|
|
|
alias esource='$EDITOR $HOME/.zshrc'
|
|
|
|
alias resource='source $HOME/.zshrc'
|
|
|
|
alias dotedit='$EDITOR $DOTFILES/brethil_dotfile.sh'
|
2017-07-17 02:00:15 +02:00
|
|
|
# Custom definitions files
|
2022-03-26 13:35:54 +01:00
|
|
|
alias funedit='$EDITOR ~/.dotfiles_functions'
|
|
|
|
alias aledit='$EDITOR ~/.dotfiles_aliases'
|
2017-06-12 16:22:05 +02:00
|
|
|
|
2020-12-09 01:11:29 +01:00
|
|
|
export p="${HOME}/projects"
|
2021-12-24 11:49:01 +01:00
|
|
|
export g="${HOME}/git"
|
2020-12-09 01:11:29 +01:00
|
|
|
|
2022-03-26 13:35:54 +01:00
|
|
|
|
|
|
|
for defname in aliases functions ; do
|
|
|
|
for def in $DOTFILES/$defname/*zsh ; do
|
|
|
|
source $def
|
|
|
|
done
|
|
|
|
done
|
|
|
|
unset def defname
|
2022-01-05 18:16:45 +01:00
|
|
|
|
|
|
|
# Extras
|
|
|
|
functions_file=~/.dotfiles_functions
|
|
|
|
aliases_file=~/.dotfiles_aliases
|
2022-02-07 20:49:25 +01:00
|
|
|
ssh_file=~/.ssh_aliases
|
2022-01-05 18:16:45 +01:00
|
|
|
|
|
|
|
( # migration of old format
|
|
|
|
if [[ -f ${functions_file}.sh ]]; then
|
|
|
|
echo "Migrating ${functions_file}.sh to ${functions_file}"
|
|
|
|
mv ${functions_file}{.sh,}
|
|
|
|
fi
|
|
|
|
if [[ -f ${aliases_file}.sh ]]; then
|
|
|
|
echo "Migrating ${aliases_file}.sh to ${aliases_file}"
|
|
|
|
mv ${aliases_file}{.sh,}
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
|
|
|
|
# Source extras
|
|
|
|
test -f "${functions_file}" && source "${functions_file}"
|
|
|
|
test -f "${aliases_file}" && source "${aliases_file}"
|
2022-02-07 20:49:25 +01:00
|
|
|
test -f "${ssh_file}" && source "${ssh_file}"
|
2022-01-05 18:16:45 +01:00
|
|
|
|
2024-04-06 21:24:30 +02:00
|
|
|
# autoload -U compinit && compinit
|
|
|
|
# autoload -U bashcompinit && bashcompinit
|
2022-11-26 00:48:21 +01:00
|
|
|
|
|
|
|
# Set DISABLE_DOTFILES_AUTOUPDATE=true to disable updates
|
|
|
|
source "${DOTFILES}/extras/check_for_update.zsh"
|