Compare commits

...

3 Commits

Author SHA1 Message Date
bretello 030903dcd7
zsh: theme: get rid of more functions 2024-04-09 16:59:12 +02:00
bretello 81d8c56836
zsh: get rid of loading message 2024-04-09 15:10:25 +02:00
bretello edc1934e83
zsh: migrate from antibody to antidote
See https://getantidote.github.io and https://github.com/mattmc3/antidote
2024-04-09 15:03:55 +02:00
5 changed files with 97 additions and 70 deletions

View File

@ -1,24 +0,0 @@
# vim:ft=zsh
djui/alias-tips
robbyrussell/oh-my-zsh
robbyrussell/oh-my-zsh path:plugins/ansible
robbyrussell/oh-my-zsh path:plugins/bgnotify
robbyrussell/oh-my-zsh path:plugins/colored-man-pages
robbyrussell/oh-my-zsh path:plugins/common-aliases
robbyrussell/oh-my-zsh path:plugins/docker
robbyrussell/oh-my-zsh path:plugins/docker-compose
robbyrussell/oh-my-zsh path:plugins/fzf
robbyrussell/oh-my-zsh path:plugins/git
robbyrussell/oh-my-zsh path:plugins/golang
robbyrussell/oh-my-zsh path:plugins/grc
robbyrussell/oh-my-zsh path:plugins/pip
robbyrussell/oh-my-zsh path:plugins/pyenv
robbyrussell/oh-my-zsh path:plugins/pylint
robbyrussell/oh-my-zsh path:plugins/sudo
robbyrussell/oh-my-zsh path:plugins/vagrant
robbyrussell/oh-my-zsh path:plugins/vi-mode
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
zsh-users/zsh-syntax-highlighting
joshskidmore/zsh-fzf-history-search
ryutok/rust-zsh-completions

View File

@ -9,10 +9,51 @@ 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"
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"
[[ -d $ZSH_CACHE_DIR ]] || mkdir -p $ZSH_CACHE_DIR
# 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
if [[ $+commands[systemctl] ]]; then
antidote bundle robbyrussell/oh-my-zsh path:plugins/systemd >>${zsh_plugins}.zsh
fi
if [[ $+commands[pacman] ]]; then
antidote bundle robbyrussell/oh-my-zsh path:plugins/archlinux >>${zsh_plugins}.zsh
elif [[ $+commands[apt-get] ]]; then
antidote bundle robbyrussell/oh-my-zsh path:plugins/debian >>${zsh_plugins}.zsh
fi
)
fi
source ${zsh_plugins}.zsh
source "$DOTFILES/themes/brethil.zsh-theme"
# Setup completion style
source $DOTFILES/completion_style.zsh
@ -25,20 +66,8 @@ else
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
@ -60,7 +89,7 @@ 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 EDITOR="vim" # if antibody_plugins.txt includes robbyrussell/oh-my-zsh path:plugins/vi-mode, this also sets `bindkey -v` # FIXME
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
@ -147,8 +176,8 @@ 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
# autoload -U compinit && compinit
# autoload -U bashcompinit && bashcompinit
# Set DISABLE_DOTFILES_AUTOUPDATE=true to disable updates
source "${DOTFILES}/extras/check_for_update.zsh"

View File

@ -30,7 +30,7 @@ function _update_dotfiles_update() {
function update_dotfiles() {
(cd $DOTFILES; git pull -q --rebase && echo "Succesfully upgraded dotfiles" || echo "Could not upgrade dotfiles.")
antibody update
(cd $DOTFILES/antidote && git pull -rebase || echo "Could not upgrade antidote")
vim -c 'PlugUpdate|PlugClean|qa!'
# update the zsh file
_update_dotfiles_update

View File

@ -3,33 +3,31 @@
# See "EXPANSION OF PROMPT SEQUENCES" in `man zshmisc`
# Note: Most of the expansions/color sequences can be tested using `print -P`
function user_prompt(){
# prints hostname on an orange background if on an ssh connection, adds username if root
local user='%(!.%K{160}%F{255}%B%n%b%k%f.)' # prints 'root' on a red background if user is root
local host='%K{202}%B%F{255}%m%f%k%b' # bold host name on an orange background
local open_bracket='%(!.[.)'
local close_bracket='%(!.].)'
local at='%(!.@.)'
if [[ -n $SSH_CONNECTION ]]; then
echo "[${user}${at}${host}]"
else
echo "${open_bracket}${user}${close_bracket}"
fi
}
local user='%(!.%K{160}%F{255}%B%n%b%k%f.)' # prints 'root' on a red background if user is root
local host='%K{202}%B%F{255}%m%f%k%b' # bold host name on an orange background
local open_bracket='%(!.[.)'
local close_bracket='%(!.].)'
local at='%(!.@.)'
local user_prompt
if [[ -n $SSH_CONNECTION ]]; then
user_prompt="[${user}${at}${host}]"
else
user_prompt="${open_bracket}${user}${close_bracket}"
fi
local job_prompt="%(1j.%B%K{202}%F{220} %j %k%b.)"
function shlvl_prompt() {
# Shows SHLVL on a magenta background if SHLVL > 1 (2 if in a tmux session)
if [[ -z "$TMUX" ]]; then
echo "%(2L.%K{161}%F{255}%B %L %f%b%k.)"
else
echo "%(3L.%K{161}%F{255}%B $((SHLVL-1)) %f%b%k.)"
fi
}
# TODO: add truncation using
local shlvl_prompt
# Shows SHLVL on a magenta background if SHLVL > 1 (2 if in a tmux session)
if [[ -z "$TMUX" ]]; then
shlvl_prompt="%(2L.%K{161}%F{255}%B %L %f%b%k.)"
else
shlvl_prompt="%(3L.%K{161}%F{255}%B $((SHLVL-1)) %f%b%k.)"
fi
# Shows last 3 items in path if there are more than 4
local path_prompt='[%F{green}%(4~:…/%3~:%~)%f]'
@ -57,12 +55,12 @@ ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="<>"
local BOLD_PURPLE='%B%F{5}'
local CLEAR='%f%b'
local venv
function virtualenv_info {
[ -z "$VIRTUAL_ENV" ] && return
local BOLD_PURPLE='%B%F{5}'
local CLEAR='%f%b'
local venv
venv="$(basename "$VIRTUAL_ENV")"
if [[ "$venv" == ".venv" ]]; then
venv="$(basename $(dirname "$VIRTUAL_ENV") )"
@ -88,7 +86,7 @@ export MODE_INDICATOR="[%B%K{red}nav%k%b]" # red background
export INSERT_MODE_INDICATOR="[%B%K{28}ins%k%b]" # green background
# put it all together
PROMPT='$(virtualenv_info)$(user_prompt)'"${path_prompt}${git_prompt}${job_prompt}"'$(shlvl_prompt)'"${prompt_too_long}${prompt_with_previous_return_status}"
PROMPT='$(virtualenv_info)'"${user_prompt}${path_prompt}${git_prompt}${job_prompt}${shlvl_prompt}${prompt_too_long}${prompt_with_previous_return_status}"
# Right prompt is just return code and time
RPS1="${return_code_RPS1}"'$(vi_mode_prompt_info)[%*]'

24
zsh_plugins.txt 100644
View File

@ -0,0 +1,24 @@
# vim:ft=zsh
djui/alias-tips
ohmyzsh/ohmyzsh path:lib
ohmyzsh/ohmyzsh path:plugins/ansible
ohmyzsh/ohmyzsh path:plugins/bgnotify
ohmyzsh/ohmyzsh path:plugins/colored-man-pages
ohmyzsh/ohmyzsh path:plugins/common-aliases
ohmyzsh/ohmyzsh path:plugins/docker
ohmyzsh/ohmyzsh path:plugins/docker-compose
ohmyzsh/ohmyzsh path:plugins/fzf
ohmyzsh/ohmyzsh path:plugins/git
ohmyzsh/ohmyzsh path:plugins/golang
ohmyzsh/ohmyzsh path:plugins/grc
ohmyzsh/ohmyzsh path:plugins/pip
ohmyzsh/ohmyzsh path:plugins/pyenv
ohmyzsh/ohmyzsh path:plugins/pylint
ohmyzsh/ohmyzsh path:plugins/sudo
ohmyzsh/ohmyzsh path:plugins/vagrant
ohmyzsh/ohmyzsh path:plugins/vi-mode
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
zsh-users/zsh-syntax-highlighting
joshskidmore/zsh-fzf-history-search
ryutok/rust-zsh-completions