Skip to content

Commit

Permalink
Simplify frameworks setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbn committed Jul 12, 2024
1 parent da00f4f commit 6f625ba
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 96 deletions.
12 changes: 4 additions & 8 deletions frameworks/antibody-static.zsh
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
() {
local -r home_dir=${1}

# install antibody
[[ ! -e ${home_dir}/bin/antibody ]] && command curl -sL git.io/antibody | sh -s - -b ${home_dir}/bin
[[ ! -e bin/antibody ]] && command curl -sL git.io/antibody | sh -s - -b bin

>>! ${home_dir}/.zsh_plugins.txt <<\END
>>! .zsh_plugins.txt <<\END
zimfw/environment
zimfw/git
zimfw/input
Expand All @@ -20,9 +17,9 @@ zsh-users/zsh-syntax-highlighting
zsh-users/zsh-history-substring-search
END

HOME=${home_dir} ANTIBODY_HOME=${home_dir}/.antibody ${home_dir}/bin/antibody bundle < ${home_dir}/.zsh_plugins.txt > ${home_dir}/.zsh_plugins.sh
HOME=${PWD} ANTIBODY_HOME=${PWD}/.antibody bin/antibody bundle < .zsh_plugins.txt > .zsh_plugins.sh

>>! ${home_dir}/.zshrc <<\END
>>! .zshrc <<\END
export ANTIBODY_HOME=~/.antibody
# antibody does not add functions subdirs to fpath, nor autoloads them!
Expand All @@ -34,4 +31,3 @@ source ~/.zsh_plugins.sh
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down
END
} "${@}"
12 changes: 4 additions & 8 deletions frameworks/antigen.zsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
() {
local -r home_dir=${1}

# download the repository
command curl -Ss -L git.io/antigen > ${home_dir}/antigen.zsh
# download the script
command curl -Ss -L git.io/antigen > antigen.zsh

# add modules to .zshrc
>>! ${home_dir}/.zshrc <<\END
>>! .zshrc <<\END
source ~/antigen.zsh
antigen bundle zimfw/environment
antigen bundle zimfw/git
Expand All @@ -30,5 +27,4 @@ bindkey "^[[B" history-substring-search-down
END

# Force reinstall, as it was failing in alpine linux
HOME=${home_dir} zsh -ic 'antigen reset'
} "${@}"
HOME=${PWD} zsh -ic 'antigen reset'
16 changes: 6 additions & 10 deletions frameworks/ohmyzsh.zsh
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
() {
local -r home_dir=${1}

# download the install script
command curl -sS -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh >${home_dir}/install.sh
command curl -sS -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh > install.sh
# also remove the automatic-start of the new terminal
# silence the git clone output
command sed -i.bak -e '/env zsh -l/d' -e 's/git clone/git clone --quiet/g' ${home_dir}/install.sh
command sed -i.bak -e '/env zsh -l/d' -e 's/git clone/git clone --quiet/g' install.sh

# run though sh as per the instructions
HOME=${home_dir} ZSH=${home_dir}/.oh-my-zsh sh ${home_dir}/install.sh --unattended
HOME=${PWD} ZSH=${PWD}/.oh-my-zsh sh install.sh --unattended

# grab zsh-syntax-highlighting
command git clone --quiet https://github.com/zsh-users/zsh-autosuggestions ${home_dir}/.oh-my-zsh/custom/plugins/zsh-autosuggestions
command git clone --quiet https://github.com/zsh-users/zsh-autosuggestions .oh-my-zsh/custom/plugins/zsh-autosuggestions

# grab zsh-syntax-highlighting
command git clone --quiet https://github.com/zsh-users/zsh-syntax-highlighting.git ${home_dir}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
command git clone --quiet https://github.com/zsh-users/zsh-syntax-highlighting.git .oh-my-zsh/custom/plugins/zsh-syntax-highlighting

# we don't need auto-update stuff
# replace the plugin string with the selected plugins
command sed -i.bak -E -e 's/^# (DISABLE_AUTO_UPDATE="true")/\1/' -e 's/^(plugins=\([^\)]*)/\1 git-prompt colored-man-pages common-aliases timer zsh-autosuggestions zsh-syntax-highlighting history-substring-search/' ${home_dir}/.zshrc
} "${@}"
command sed -i.bak -E -e 's/^# (DISABLE_AUTO_UPDATE="true")/\1/' -e 's/^(plugins=\([^\)]*)/\1 git-prompt colored-man-pages common-aliases timer zsh-autosuggestions zsh-syntax-highlighting history-substring-search/' .zshrc
20 changes: 8 additions & 12 deletions frameworks/prezto.zsh
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
() {
local -r home_dir=${1}

# download the repository
command git clone --quiet --recursive https://github.com/sorin-ionescu/prezto.git "${home_dir}/.zprezto"
# clone the repository
command git clone --quiet --recursive https://github.com/sorin-ionescu/prezto.git .zprezto

# follow the install instructions
setopt LOCAL_OPTIONS EXTENDED_GLOB
local rcfile
for rcfile in "${home_dir}"/.zprezto/runcoms/^README.md(.N); do
command ln -s "${rcfile}" "${home_dir}/.${rcfile:t}"
for rcfile in .zprezto/runcoms/^README.md(.N); do
command ln -s "${rcfile}" ".${rcfile:t}"
done

# add the modules to the .zpreztorc file
command rm -f ${home_dir}/.zpreztorc
command cp ${home_dir}/.zprezto/runcoms/zpreztorc ${home_dir}/.zpreztorc
command sed -i.bak -E -e "/^ *'spectrum' \\\\/d" -e "s/^( *'prompt')/\\1 'git' 'autosuggestions' 'syntax-highlighting' 'history-substring-search'/" ${home_dir}/.zpreztorc
command rm -f .zpreztorc
command cp .zprezto/runcoms/zpreztorc .zpreztorc
command sed -i.bak -E -e "/^ *'spectrum' \\\\/d" -e "s/^( *'prompt')/\\1 'git' 'autosuggestions' 'syntax-highlighting' 'history-substring-search'/" .zpreztorc

# start login shell
HOME=${home_dir} zsh -lc 'exit'
} "${@}"
HOME=${PWD} zsh -lc 'exit'
6 changes: 1 addition & 5 deletions frameworks/vanilla.zsh
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
() {
local -r home_dir=${1}

# just set PS1
>>! ${home_dir}/.zshrc <<\END
>>! .zshrc <<\END
PS1="%~%# "
END
} "${@}"
12 changes: 4 additions & 8 deletions frameworks/zcomet.zsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
() {
local -r home_dir=${1}

git clone https://github.com/agkozak/zcomet.git ${home_dir}
# clone the repository
git clone https://github.com/agkozak/zcomet.git .zcomet/bin

# add modules to .zshrc
>! ${home_dir}/.zshrc <<\END
source ~/zcomet.zsh
>! .zshrc <<\END
source ~/.zcomet/bin/zcomet.zsh
zcomet load zimfw/environment
zcomet load zimfw/git
zcomet load zimfw/input
Expand All @@ -24,5 +22,3 @@ zcomet load zsh-users/zsh-history-substring-search
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down
END

} "${@}"
10 changes: 3 additions & 7 deletions frameworks/zgen.zsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
() {
local -r home_dir=${1}

# download the repository
command git clone --quiet https://github.com/tarjoilija/zgen.git ${home_dir}/.zgen
# clone the repository
command git clone --quiet https://github.com/tarjoilija/zgen.git .zgen

# add modules to .zshrc
>>! ${home_dir}/.zshrc <<\END
>>! .zshrc <<\END
ZGEN_AUTOLOAD_COMPINIT=0
# zgen does not add functions subdirs to fpath, nor autoloads them!
Expand Down Expand Up @@ -33,4 +30,3 @@ fi
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down
END
} "${@}"
8 changes: 2 additions & 6 deletions frameworks/zim.zsh
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
() {
local -r home_dir=${1}

# download the repository
command curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | HOME=${home_dir} zsh
} "${@}"
# download the install script
command curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | HOME=${PWD} zsh
13 changes: 4 additions & 9 deletions frameworks/zinit-light.zsh
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
() {
local -r home_dir=${1}

# download the repository
command mkdir ${home_dir}/.zinit
command git clone --quiet https://github.com/zdharma-continuum/zinit.git ${home_dir}/.zinit/bin
# clone the repository
command git clone --quiet https://github.com/zdharma-continuum/zinit.git .zinit/bin

# add modules to .zshrc
>>! ${home_dir}/.zshrc <<\END
>>! .zshrc <<\END
PS1="%~%# "
source ~/.zinit/bin/zinit.zsh
zinit light "zimfw/environment"
Expand Down Expand Up @@ -37,5 +33,4 @@ bindkey "^[[B" history-substring-search-down
END

# compile the plugins
HOME=${home_dir} zsh -ic 'zinit compile --all; exit'
} "${@}"
HOME=${PWD} zsh -ic 'zinit compile --all; exit'
13 changes: 4 additions & 9 deletions frameworks/zinit-turbo.zsh
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
() {
local -r home_dir=${1}

# download the repository
command mkdir ${home_dir}/.zinit
command git clone --quiet https://github.com/zdharma-continuum/zinit.git ${home_dir}/.zinit/bin
# clone the repository
command git clone --quiet https://github.com/zdharma-continuum/zinit.git .zinit/bin

# add modules to .zshrc
>>! ${home_dir}/.zshrc <<\END
>>! .zshrc <<\END
source ~/.zinit/bin/zinit.zsh
zinit wait lucid for "zimfw/environment"
zinit wait lucid autoload"git-alias-lookup;git-branch-current;git-branch-delete-interactive;git-branch-remote-tracking;git-dir;git-ignore-add;git-root;git-stash-clear-interactive;git-stash-recover;git-submodule-move;git-submodule-remove" for "zimfw/git"
Expand All @@ -23,5 +19,4 @@ zinit wait"0c" lucid atload"zicompinit;zicdreplay;bindkey \"^[[A\" history-subst
END

# compile the plugins
HOME=${home_dir} zsh -ic 'zinit compile --all; exit'
} "${@}"
HOME=${PWD} zsh -ic 'zinit compile --all; exit'
12 changes: 4 additions & 8 deletions frameworks/zplug.zsh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
() {
local -r home_dir=${1}

# download the repository
command git clone --quiet https://github.com/zplug/zplug ${home_dir}/.zplug
# clone the repository
command git clone --quiet https://github.com/zplug/zplug .zplug

# add modules to .zshrc
>>! ${home_dir}/.zshrc <<\END
>>! .zshrc <<\END
source ~/.zplug/init.zsh
zplug "zimfw/environment"
zplug "zimfw/git"
Expand All @@ -27,5 +24,4 @@ fi
END

# install the plugins
HOME=${home_dir} zsh -ic 'zplug install; exit'
} "${@}"
HOME=${PWD} zsh -ic 'zplug install; exit'
5 changes: 0 additions & 5 deletions frameworks/zsh4humans.zsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
(

emulate -L zsh -o err_return -o no_unset -o no_aliases
cd -- $1
# download zsh4humans v5
local v=5
curl -fsSLO https://github.com/romkatv/zsh4humans/archive/refs/heads/v${v}.tar.gz
Expand All @@ -23,5 +20,3 @@ mkdir -p .cache/zsh4humans/v5/stickycache
touch .cache/zsh4humans/v5/stickycache/no-chsh
# initialize zsh4humans
HOME=${PWD} zsh -ic 'exit' </dev/null

)
2 changes: 1 addition & 1 deletion run.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ set_up() {
# source the installer
print "::group::Setting up ${1} ..."
{
source frameworks/${1}.zsh ${home_dir}
( cd ${home_dir} && source ${run_dir}/frameworks/${1}.zsh || return 1 )
} always {
print '\n::endgroup::'
}
Expand Down

0 comments on commit 6f625ba

Please sign in to comment.