From d343002dde0b30ccadd48c9978f25e0bd70f4797 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 24 Jan 2023 10:06:40 -0600 Subject: [PATCH] refactor: sheldon is dead long live chezmoi --- .gitignore | 1 + home/.chezmoiexternal.yaml | 52 ++++++++++++++++++++++++++++++++++++++ home/dot_zshrc | 2 +- lib/completions/update.sh | 2 +- lib/fzf.zsh | 1 + lib/plugins.zsh | 22 ++++++++++++++++ lib/prompt.zsh | 6 ----- 7 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 home/.chezmoiexternal.yaml create mode 100755 lib/plugins.zsh diff --git a/.gitignore b/.gitignore index eb5da14..9effff1 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,4 @@ cython_debug/ # End of https://www.toptal.com/developers/gitignore/api/python .task.mk +lib/plugins/ diff --git a/home/.chezmoiexternal.yaml b/home/.chezmoiexternal.yaml new file mode 100644 index 0000000..5d44e7c --- /dev/null +++ b/home/.chezmoiexternal.yaml @@ -0,0 +1,52 @@ +.dotfiles/lib/plugins/base16: + rereshPeriod: 168h + type: git-repo + url: https://github.com/chriskempson/base16-shell.git + +.dotfiles/lib/plugins/zsh-defer: + rereshPeriod: 168h + type: git-repo + url: https://github.com/romkatv/zsh-defer.git + +.dotfiles/lib/plugins/zsh-syntax-highlighting: + rereshPeriod: 168h + type: git-repo + url: https://github.com/zsh-users/zsh-syntax-highlighting.git + +.dotfiles/lib/plugins/fzf-tab: + rereshPeriod: 168h + type: git-repo + url: https://github.com/Aloxaf/fzf-tab.git +.dotfiles/lib/plugins/oh-my-zsh: + type: "archive" + url: https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz + # exact: true + # chezmoi refuses to mkdir with nested directories + stripComponents: 2 + refreshPeriod: "168h" + include: + - "*/lib/{clipboard,completion}.zsh" + - "*/plugins/{dotenv,extract}/**" +# +# include: +# +# - "*/plugins/{dotenv,extract}/**/*" +# include: ["plugins/dotenv/**", "plugins/extract/**"] + +# .oh-my-zsh: +# exact: true +# refreshPeriod: 168h +# stripComponents: 1 +# type: archive +# url: https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz +# .oh-my-zsh/custom/plugins/zsh-syntax-highlighting: +# exact: true +# refreshPeriod: 168h +# stripComponents: 1 +# type: archive +# url: https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz +# .oh-my-zsh/custom/themes/powerlevel10k: +# exact: true +# stripComponents: 1 +# type: archive +# url: https://github.com/romkatv/powerlevel10k/archive/v1.15.0.tar.gz diff --git a/home/dot_zshrc b/home/dot_zshrc index 087fcdd..b2ed2ad 100644 --- a/home/dot_zshrc +++ b/home/dot_zshrc @@ -12,7 +12,7 @@ fi PATH="$DOTFILES_DIR/bin:$PATH" . $DOTFILES_DIR/lib/function.zsh -for DOTFILE in "$DOTFILES_DIR"/lib/{path,env,prompt,alias,conda,custom}.zsh; do +for DOTFILE in "$DOTFILES_DIR"/lib/{path,env,prompt,alias,conda,plugins,custom}.zsh; do [ -f "$DOTFILE" ] && . "$DOTFILE" done diff --git a/lib/completions/update.sh b/lib/completions/update.sh index c102e1c..65edee1 100755 --- a/lib/completions/update.sh +++ b/lib/completions/update.sh @@ -5,7 +5,7 @@ CURDIR=${0:a:h} gen() { if is-executable $1; then echo "$1 updated" - "$@" | sed "s#$HOME#\$HOME#g" > $CURDIR/"_$argv[1]" + "$@" | sed "s#$HOME#\$HOME#g" >$CURDIR/"_$argv[1]" else echo "skipping $1" fi diff --git a/lib/fzf.zsh b/lib/fzf.zsh index 25ea6d7..34c4e6b 100755 --- a/lib/fzf.zsh +++ b/lib/fzf.zsh @@ -34,6 +34,7 @@ export FZF_DEFAULT_OPTS=${FZF_COLORS}${FZF_LAYOUT} export FZF_CTRL_GENERAL="--height=100% --margin=0,0,0" #adapted from https://github.com/zimfw/fzf/blob/master/init.zsh +# TODO: fix this so it works with $ ** if [ -x "$(command -v fd)" ]; then export FZF_DEFAULT_COMMAND="command fd --type file --exclude ".git/" --hidden --no-ignore" _fzf_compgen_path() { diff --git a/lib/plugins.zsh b/lib/plugins.zsh new file mode 100755 index 0000000..b7a38b9 --- /dev/null +++ b/lib/plugins.zsh @@ -0,0 +1,22 @@ +#!/usr/bin/env zsh + +PLUGINS_DIR=$DOTFILES_DIR/lib/plugins + +source $PLUGINS_DIR/zsh-defer/zsh-defer.plugin.zsh + +# TODO: automate collection of plugin files +plugins=( + base16/base16-shell.plugin.zsh + fzf-tab/fzf-tab.plugin.zsh + zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh + oh-my-zsh/clipboard.zsh + oh-my-zsh/completion.zsh + oh-my-zsh/dotenv/dotenv.plugin.zsh + oh-my-zsh/extract/extract.plugin.zsh +) + +for plugin in $plugins; do + zsh-defer source $PLUGINS_DIR/$plugin +done + +unset PLUGINS_DIR plugins diff --git a/lib/prompt.zsh b/lib/prompt.zsh index 80b3d25..e6e82f5 100755 --- a/lib/prompt.zsh +++ b/lib/prompt.zsh @@ -3,12 +3,6 @@ autoload -Uz compinit compinit -if is-executable sheldon; then - eval "$(sheldon -q --config-file ~/.config/sheldon/plugins.toml source)" -else - echo "no sheldon = no shell extensions loaded" -fi - is-executable zoxide && eval eval "$(zoxide init zsh --cmd cd)" if is-executable starship; then