Add install.zsh for standalone installs
This commit is contained in:
parent
a9fb5104ac
commit
3130086d07
70
install.zsh
Executable file
70
install.zsh
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
error() {
|
||||||
|
echo "error: $*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
directories=(
|
||||||
|
~/.cache/zsh
|
||||||
|
~/.local/bin
|
||||||
|
~/.local/share/zsh/plugins
|
||||||
|
~/.local/share/zsh/site-functions
|
||||||
|
)
|
||||||
|
for directory in $directories; do
|
||||||
|
mkdir -p $directory
|
||||||
|
done
|
||||||
|
|
||||||
|
plugins=(
|
||||||
|
zsh-users/zsh-autosuggestions
|
||||||
|
zsh-users/zsh-history-substring-search
|
||||||
|
zsh-users/zsh-syntax-highlighting
|
||||||
|
zsh-users/zsh-completions
|
||||||
|
)
|
||||||
|
for plugin in $plugins; do
|
||||||
|
plugin_directory=~/.local/share/zsh/plugins/${plugin/*\//}
|
||||||
|
if [ -d $plugin_directory ]; then
|
||||||
|
if ! git -C $plugin_directory diff-index --quiet HEAD --; then
|
||||||
|
error $plugin_directory contains unstaged changes
|
||||||
|
fi
|
||||||
|
pull=`git -C $plugin_directory pull`
|
||||||
|
if [ "$pull" != "Already up-to-date." ]; then
|
||||||
|
echo changed
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
git clone https://github.com/$plugin.git $plugin_directory > /dev/null
|
||||||
|
echo changed
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
declare -A symlinks
|
||||||
|
symlinks=(
|
||||||
|
~/.config/zsh/zlogin ~/.zlogin
|
||||||
|
~/.config/zsh/zlogout ~/.zlogout
|
||||||
|
~/.config/zsh/zprofile ~/.zprofile
|
||||||
|
~/.config/zsh/zshenv ~/.zshenv
|
||||||
|
~/.config/zsh/zshrc ~/.zshrc
|
||||||
|
~/.config/zsh/prompt_fresh_setup
|
||||||
|
~/.local/share/zsh/site-functions/prompt_fresh_setup
|
||||||
|
~/.config/zsh/build/_build-dir ~/.local/share/zsh/site-functions/_build-dir
|
||||||
|
~/.config/zsh/sandbox/_sandbox ~/.local/share/zsh/site-functions/_sandbox
|
||||||
|
~/.config/zsh/layout/_layout ~/.local/share/zsh/site-functions/_layout
|
||||||
|
~/.config/zsh/notes/_note ~/.local/share/zsh/site-functions/_note
|
||||||
|
~/.config/zsh/cmake-uninstall ~/.local/bin/cmake-uninstall
|
||||||
|
~/.config/zsh/$ ~/.local/bin/$
|
||||||
|
~/.config/zsh/url/url ~/.local/bin/url
|
||||||
|
~/.config/zsh/url/_url ~/.local/share/zsh/site-functions/_url
|
||||||
|
)
|
||||||
|
for source in ${(k)symlinks}; do
|
||||||
|
dest=$symlinks[$source]
|
||||||
|
if [ -L $dest ]; then
|
||||||
|
target=`readlink $dest`
|
||||||
|
if [ "$target" != "$source" ]; then
|
||||||
|
error symlink failed $dest exists but links to $target not $source
|
||||||
|
fi
|
||||||
|
elif [ -f $dest ]; then
|
||||||
|
error symlink failed $dest exists but is a regular file
|
||||||
|
else
|
||||||
|
ln -s $source $dest
|
||||||
|
fi
|
||||||
|
done
|
8
zshrc
8
zshrc
@ -3,8 +3,12 @@
|
|||||||
|
|
||||||
# Load plugin scripts
|
# Load plugin scripts
|
||||||
source-plugin() {
|
source-plugin() {
|
||||||
if [ -d ~/.config/zsh/$1 ]; then
|
local shared_plugin=~/.local/share/zsh/plugins/$1/$1.plugin.zsh
|
||||||
source ~/.config/zsh/$1/$1.plugin.zsh
|
local local_plugin=~/.config/zsh/$1/$1.plugin.zsh
|
||||||
|
if [ -f $shared_plugin ]; then
|
||||||
|
source $shared_plugin
|
||||||
|
elif [ -f $local_plugin ]; then
|
||||||
|
source $local_plugin
|
||||||
else
|
else
|
||||||
echo "zsh plugin not found: $1"
|
echo "zsh plugin not found: $1"
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user