From 4d93b9e061a23e6d0c9288345db515b2c9ff693a Mon Sep 17 00:00:00 2001 From: waldek Date: Wed, 24 Aug 2022 21:04:22 +0200 Subject: [PATCH] port to function based script --- .gitignore | 1 + bootstrap.sh | 115 ++++++++++++++++++++++++++++++++++++++++++++------- custom.zsh | 16 +++++++ env.sh | 14 +++++++ 4 files changed, 130 insertions(+), 16 deletions(-) create mode 100644 .gitignore create mode 100644 custom.zsh create mode 100644 env.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/bootstrap.sh b/bootstrap.sh index 49841f4..5259027 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,23 +1,106 @@ #!/bin/bash -ME="waldek" -LOCALHOME="/home/" +NAME="waldek" +EMAIL="waldek@mailbox.org" +DEPENDENCIES_APT="zsh git tig tmux vim-nox htop python3 python3-pip" -if [ $USER != $ME ]; then +LOCALHOME="/home/" +SOURCES_DIR=~/sources +BOOTSTRAP_DIR=~/sources/bootstrap +CUSTOM_ZSHRC=$BOOTSTRAP_DIR/custom.zsh +CUSTOM_ENV=$BOOTSTRAP_DIR/env.sh + +if [[ -z $(groups | grep sudo) ]]; then echo "you need to run this script as yourself, but you need to be in the sudo group..." exit 1 +else + echo "all good! let's setup your system" fi -echo "setting up $ME" -HOME=$LOCALHOME$ME -sudo apt update && sudo apt install -y zsh git tig tmux vim-nox htop -cd $HOME -git clone git://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh -cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc -sudo chsh -s /bin/zsh $ME -mkdir $HOME/sources -git clone https://gitea.86thumbs.net/waldek/vimrc.git $HOME/sources/vimrc -cd $HOME -ln -s $HOME/sources/vimrc/main.vimrc $HOME/.vimrc -git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim -vim +VundleInstall +qall +function install_apt_dependencies () { + sudo apt-get update > /dev/null && echo "cache updated" + for pgm in $DEPENDENCIES_APT; do + sudo apt-get install -y $pgm > /dev/null && echo "$pgm installed" + done + echo "--- ${FUNCNAME[0]} done" +} + +function setup_sources_dir () { + local dst=$SOURCES_DIR + if ! [[ -d $dst ]]; then + mkdir -p $dst && echo "created $dst directory" + else + echo "$dst exists already" + fi + echo "--- ${FUNCNAME[0]} done" +} + +function setup_global_git_config () { + content=$(cat << EOF +\n +[user]\n +\tname = $NAME\n +\temail = $EMAIL\n +[filter "lfs"]\n +\tclean = git-lfs clean -- %f\n +\tsmudge = git-lfs smudge -- %f\n +\tprocess = git-lfs filter-process\n +\trequired = true\n +[pull]\n +\trebase = false\n +EOF +) + echo -e $content > ~/.gitconfig + echo "--- ${FUNCNAME[0]} done" +} + +function clone_bootstrap_to_sources_dir () { + local dst=~/sources/bootstrap + if ! [[ -d $dst ]]; then + git clone ssh://gitea@86thumbs.net:3022/waldek/bootstrap.git $dst && echo "cloned bootstrap dir" + fi + echo "--- ${FUNCNAME[0]} done" +} + +function install_oh_my_zsh () { + local dst=~/.oh-my-zsh + if ! [[ -d $dst ]]; then + git clone git://github.com/robbyrussell/oh-my-zsh.git $dst + cp $dst/templates/zshrc.zsh-template ~/.zshrc + else + cd $dst + git pull + fi + echo "--- ${FUNCNAME[0]} done" +} + +function customize_oh_my_zsh () { + if [[ -z $(grep $CUSTOM_ZSHRC ~/.zshrc) ]]; then + echo "source $CUSTOM_ZSHRC" >> ~/.zshrc && echo "appended $CUSTOM_ZSHRC to zshrc" + fi + if [[ -z $(grep $CUSTOM_ENV ~/.zshrc) ]]; then + echo "source $CUSTOM_ENV" >> ~/.zshrc && echo "appended $CUSTOM_ENV to zshrc" + fi + echo "--- ${FUNCNAME[0]} done" +} + +#install_apt_dependencies +setup_sources_dir +setup_global_git_config +clone_bootstrap_to_sources_dir +install_oh_my_zsh +customize_oh_my_zsh + +#echo "setting up $ME" +#HOME=$LOCALHOME$ME +#sudo apt update && sudo apt install -y zsh git tig tmux vim-nox htop +#cd $HOME +#git clone git://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh +#cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc +#sudo chsh -s /bin/zsh $ME +#mkdir $HOME/sources +#git clone https://gitea.86thumbs.net/waldek/vimrc.git $HOME/sources/vimrc +#cd $HOME +#ln -s $HOME/sources/vimrc/main.vimrc $HOME/.vimrc +#git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim +#vim +VundleInstall +qall diff --git a/custom.zsh b/custom.zsh new file mode 100644 index 0000000..df77c02 --- /dev/null +++ b/custom.zsh @@ -0,0 +1,16 @@ + +# START customization via bootstrap script + +COMPLETION_WAITING_DOTS="true" +plugins=(git autoswitch_virtualenv tty-solarized) +#zstyle :omz:plugins:tty-solarized theme-shade "light" +zstyle :omz:plugins:tty-solarized theme-shade "dark" +alias meteo="wget -q -O - wttr.in" +source ~/.environment_vars.sh +export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" +# makes shift tab work in tty +bindkey '\E\t' reverse-menu-complete +export PATH=$PATH:/usr/local/go/bin + +# END customization via bootstrap script + diff --git a/env.sh b/env.sh new file mode 100644 index 0000000..9db4242 --- /dev/null +++ b/env.sh @@ -0,0 +1,14 @@ +# general variables +export FPATH=$FPATH:/usr/share/zsh +export PATH=$PATH:~/.local/bin:~/bin/python/ +export EDITOR=vim + +# python virtualenv varibles +export AUTOSWITCH_DEFAULTENV="baseline" +export AUTOSWITCH_SILENT=1 + +# wayland variables +export MOZ_ENABLE_WAYLAND=1 +export QT_QPA_PLATFORM=wayland +export XDG_SESSION_TYPE=wayland +export GDK_BACKEND=wayland