mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-12 23:01:31 +01:00
155 lines
4.6 KiB
Bash
Executable File
155 lines
4.6 KiB
Bash
Executable File
# vim:ft=zsh ts=2 sw=2 sts=2
|
|
export LANG=en_US.UTF-8
|
|
|
|
# theme-related variables
|
|
export ZSH_CUSTOM="$DOTFILES"
|
|
export ZSH_THEME="brethil"
|
|
export DISABLE_UNTRACKED_FILES_DIRTY=true
|
|
export VIRTUAL_ENV_DISABLE_PROMPT=true
|
|
|
|
export PATH=$PATH:$HOME/bin
|
|
|
|
# Source all zsh plugins
|
|
source <(antibody init)
|
|
export ANTIBODY="$(antibody home)"
|
|
antibody bundle < "$DOTFILES/antibody_plugins.txt"
|
|
|
|
# Setup completion style
|
|
source $DOTFILES/completion_style.zsh
|
|
source $DOTFILES/extras/fzf-tab-config.zsh
|
|
|
|
if [[ $+commands[fd] ]]; then
|
|
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)'"
|
|
|
|
if [[ $+commands[systemctl] ]]; then
|
|
antibody bundle robbyrussell/oh-my-zsh path:plugins/systemd
|
|
fi
|
|
if [[ $+commands[pacman] ]]; then
|
|
antibody bundle robbyrussell/oh-my-zsh path:plugins/archlinux
|
|
elif [[ $+commands[apt-get] ]]; then
|
|
antibody bundle robbyrussell/oh-my-zsh path:plugins/debian
|
|
fi
|
|
|
|
ZSH_HIGHLIGHT_STYLES[comment]='fg=white,bg=gray,bold'
|
|
|
|
# Setup oh-my-zsh path
|
|
export ZSH="$(antibody path robbyrussell/oh-my-zsh)"
|
|
|
|
# Enable zsh autocorrection
|
|
setopt CORRECT_ALL
|
|
|
|
# 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
|
|
|
|
# Silence completion beeps
|
|
unsetopt LIST_BEEP
|
|
|
|
|
|
## Misc environment variables
|
|
|
|
# https://www.xkcd.com/378/
|
|
export EDITOR="vim" # if antibody_plugins.txt includes robbyrussell/oh-my-zsh path:plugins/vi-mode, this also sets `bindkey -v`
|
|
export VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true # refresh prompt on every mode change
|
|
# Fix delete (delete! not backspace) key
|
|
bindkey -a '^[[3~' delete-char
|
|
|
|
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
|
|
|
|
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
|
|
|
|
export HISTSIZE=10000000
|
|
export SAVEHIST=10000000
|
|
|
|
|
|
# zsh-autosuggestions config
|
|
export ZSH_AUTOSUGGEST_STRATEGY=(history completion)
|
|
export ZSH_AUTOSUGGEST_COMPLETION_IGNORE='* \#*' # prevent completion for comments
|
|
|
|
# less options
|
|
export LESS='-xRF-j12' # -j12: displays 12 lines before search results with / and ?
|
|
if [[ $+commands[bat] || $+commands[batcat] ]]; then
|
|
if [[ $+commands[bat] ]]; then cmd=bat else cmd=batcat fi
|
|
|
|
alias cat=$cmd
|
|
export PAGER=$cmd
|
|
export BAT_PAGER="less $LESS"
|
|
|
|
if [[ -n $THEME_PREFER_LIGHT ]]; then
|
|
export BAT_THEME="gruvbox-light"
|
|
else
|
|
export BAT_THEME="gruvbox-dark"
|
|
fi
|
|
|
|
## this breaks symlink testing with [ -h ], best not to activate it
|
|
# alias -g -- -h='-h 2>&1 | bat --language=help --style=plain'
|
|
alias bathelp="$cmd --language=help --style=plain"
|
|
alias -g -- --help='--help 2>&1 | bathelp '
|
|
fi
|
|
|
|
if [[ $SSH_CLIENT ]]; then
|
|
export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
|
|
fi
|
|
|
|
# Automatically enable/disable virtualenv on chdir/step
|
|
export DOTFILES_AUTOSWITCH_VIRTUALENV=1
|
|
|
|
alias esource='$EDITOR $HOME/.zshrc'
|
|
alias resource='source $HOME/.zshrc'
|
|
alias dotedit='$EDITOR $DOTFILES/brethil_dotfile.sh'
|
|
# Custom definitions files
|
|
alias funedit='$EDITOR ~/.dotfiles_functions'
|
|
alias aledit='$EDITOR ~/.dotfiles_aliases'
|
|
|
|
export p="${HOME}/projects"
|
|
export g="${HOME}/git"
|
|
|
|
|
|
for defname in aliases functions ; do
|
|
for def in $DOTFILES/$defname/*zsh ; do
|
|
source $def
|
|
done
|
|
done
|
|
unset def defname
|
|
|
|
# Extras
|
|
functions_file=~/.dotfiles_functions
|
|
aliases_file=~/.dotfiles_aliases
|
|
ssh_file=~/.ssh_aliases
|
|
|
|
( # 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}"
|
|
test -f "${ssh_file}" && source "${ssh_file}"
|
|
|
|
autoload -U compinit && compinit
|
|
autoload -U bashcompinit && bashcompinit
|
|
|
|
# Set DISABLE_DOTFILES_AUTOUPDATE=true to disable updates
|
|
source "${DOTFILES}/extras/check_for_update.zsh"
|