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