1
1
Fork 0

working on zsh setup script

This commit is contained in:
david 2018-05-13 23:09:32 +02:00
parent 48151a36ec
commit fa44d6abfd
1 changed files with 36 additions and 17 deletions

53
setup_zsh.sh Normal file → Executable file
View File

@ -13,6 +13,7 @@ root="$HOME/.dotfiles"
plugins="$root/zsh"
timestamp=$(date +"%Y%m%d%H%M")
debug=1
remove=".dotfiles .dotfiles.old .myzsh .oh-my-zsh .zshrc .zshrc-pre-oh-my-zsh"
dependencies="awk tee ls git wget curl rm mv sleep date"
if [ $(uname) == "Darwin" ]; then
alias sed="gsed"
@ -81,28 +82,44 @@ cleanup() {
message d "Warming up installer."
#message d "Initiating preflight checks."
# check dependencies, fail with a list of missing
# can i write to ~ and ~/.oh-my-zsh
# check dependencies
missing=""
for item in $dependencies; do
command -v $item > /dev/null
if [ $? -ne 0 ]; then
missing="$missing $item"
fi
done
if [ -n "$missing" ]; then
message e "dependencies missing: $missing"
exit 1
fi
message i "all dependencies found"
# remove everything in 5 seconds: ~/.dotfiles ~/.dotfiles.old ~/.myzsh ~/.oh-my-zsh ~/.zshrc
message w "your old configs will be deleted in 5 seconds [terminate deletion with Ctrl-C]"
sleep 5
rm -rf $HOME/.dotfiles
rm -rf $HOME/.dotfiles.old
rm -rf $HOME/.myzsh
rm -rf $HOME/.oh-my-zsh
rm $HOME/.zshrc
rm $HOME/.zshrc.pre-oh-my-zsh
for item in $remove; do
if [ -d $item ]; then
rm -rf $HOME/$item
message w "removed folder: ~/$item"
elif [ -h $item ]; then
rm $HOME/$item
message w "removed link: ~/$item"
elif [ -f $item ]; then
rm $HOME/$item
message w "removed file: ~/$item"
fi
done
# invoke oh-my-zh installer
curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash
message i "oh-my-zsh installed"
# set $ZSH_THEME="" in .zshrc
sed -i "s/^ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"\"/g" $HOME/.zshrc
message i "oh-my-zsh theme deactivated"
if [ -w $HOME ]; then
curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash
message i "oh-my-zsh installed"
else
message e "oh-my-zsh could not be installed. $HOME is not writeable"
exit 1
fi
# clone plugins
cd $HOME/.oh-my-zsh/custom/plugins/ > /dev/null
@ -116,11 +133,13 @@ git clone https://github.com/zsh-users/zsh-autosuggestions.git zsh-autosuggestio
cd - > /dev/null
message i "all plugins cloned"
# set $ZSH_THEME="" in .zshrc
sed -i "s/^ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"\"/g" $HOME/.zshrc
# set $plugins in .zshrc
plugins="git zsh-autosuggestions autoupdate sysadmin-util zsh-syntax-highlighting zsh-david async pure"
sed -i "/plugins=(/,/)/d; s/source \$ZSH\/oh-my-zsh.sh/plugins=($plugins);; source \$ZSH\/oh-my-zsh.sh/g" $HOME/.zshrc
sed -i $'s/;; /\\\n/g' $HOME/.zshrc
message i "activated zsh plugins [$plugins]"
message i "tweaked ~/.zshrc"
message d "Installer finished."