dotwryn/setup

195 lines
4.9 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2020-09-10 19:38:42 +00:00
################################################################################
### SHELL SETUP ################################################################
################################################################################
2020-09-10 19:38:42 +00:00
function SOURCE_DOTWRYN_RC {
local HOME_RC="$1";
local WRYN_RC="$2";
[ ! -f "$HOME/$HOME_RC" ] && touch "$HOME/$HOME_RC";
grep -q '\.wryn' "$HOME/$HOME_RC" \
&& echo "already set up $HOME_RC" \
|| {
echo "source $WRYN_RC" >> "$HOME/$HOME_RC";
echo "successfully set up $HOME_RC";
}
}
2020-09-10 19:38:42 +00:00
function SHELL__SETUP {
SOURCE_DOTWRYN_RC '.bashrc' '$HOME/.wryn/bash/rc'
which bash >/dev/null && "$HOME/.wryn/env/env.bash";
2020-09-10 19:38:42 +00:00
SOURCE_DOTWRYN_RC '.zshrc' '$HOME/.wryn/zsh/rc';
which zsh >/dev/null && "$HOME/.wryn/env/env.zsh";
}
2020-01-08 19:40:53 +00:00
2020-09-10 19:52:16 +00:00
2020-09-10 19:38:42 +00:00
################################################################################
### VIM SETUP ##################################################################
################################################################################
2020-01-08 19:40:53 +00:00
2020-09-10 19:38:42 +00:00
function VIM__SETUP_ENVIRONMENT_VARIABLES() {
VIM_ENV="$HOME/.config/wryn/env.vim";
2020-01-08 19:40:53 +00:00
2020-09-10 19:38:42 +00:00
[ ! -f "$VIM_ENV" ] && {
touch "$VIM_ENV";
2020-01-08 19:40:53 +00:00
which google-chrome-stable \
2020-09-10 19:38:42 +00:00
&& echo 'let $WEBBROWSER="'$(which google-chrome-stable)'"' >> $VIM_ENV\
|| echo 'let $WEBBROWSER=""' >> $VIM_ENV;
2020-01-08 19:40:53 +00:00
} || {
2020-01-08 20:04:01 +00:00
echo 'vim environment variables already set up';
2020-01-08 19:40:53 +00:00
}
2020-09-10 19:38:42 +00:00
}
function VIM__UPDATE_COLORSCHEMES() {
pushd $HOME/.wryn/config/colorschemes/vim >/dev/null
./update_colorschemes
popd >/dev/null
}
function VIM__INSTALL_VUNDLE_PLUGINS() {
[ ! -d "$HOME/.vim" ] && mkdir "$HOME/.vim"
[ ! -d "$HOME/.vim/bundle" ] && mkdir "$HOME/.vim/bundle"
[ ! -d "$HOME/.vim/bundle/Vundle.vim" ] && {
echo "installing vundle";
git clone https://github.com/VundleVim/Vundle.vim.git "$HOME/.vim/bundle/Vundle.vim";
}
echo "installing vundle plugins"
vim +PluginInstall +qall;
2019-12-02 17:16:05 +00:00
2020-09-10 19:38:42 +00:00
echo "building plugins"
$HOME/.wryn/vim/rebuild_plugins;
}
function VIM__SETUP() {
echo 'setting up vim';
SOURCE_DOTWRYN_RC '.vimrc' '$HOME/.wryn/vim/rc.vim';
VIM__SETUP_ENVIRONMENT_VARIABLES;
VIM__UPDATE_COLORSCHEMES;
VIM__INSTALL_VUNDLE_PLUGINS;
echo 'vim setup complete';
}
################################################################################
### LINK CONFIGURATION FILES ###################################################
################################################################################
2020-01-08 20:04:01 +00:00
2020-09-10 19:38:42 +00:00
function CONFIG__BASIC_SYMLINK() {
local HOME_CONFIG="$1";
local WRYN_CONFIG="$2";
mv "$HOME_CONFIG" "$HOME_CONFIG.bak"; # >/dev/null 2>&1;
ln -s "$WRYN_CONFIG" "$HOME_CONFIG";
}
function CONFIG__SYMLINK() {
local CONFIG_DIR="$1";
local FILENAME="$2";
local HOME_CONFIG_DIR="$HOME/.config/$CONFIG_DIR";
local HOME_CONFIG="$HOME_CONFIG_DIR/$FILENAME";
local WRYN_CONFIG="$HOME/.wryn/.config/$CONFIG_DIR/$FILENAME";
[ ! -d "$HOME_CONFIG_DIR" ] && mkdir "$HOME_CONFIG_DIR";
CONFIG__BASIC_SYMLINK $HOME_CONFIG $WRYN_CONFIG;
}
function CONFIG__I3() {
CONFIG__SYMLINK "i3" "config";
echo "linked i3 configuration"
}
function CONFIG__COMPTON() {
CONFIG__SYMLINK "compton" "compton.conf";
echo "linked compton configuration"
}
function CONFIG__KITTY() {
CONFIG__SYMLINK "kitty" "kitty.conf";
CONFIG__SYMLINK "kitty" "theme.conf";
echo "linked kitty configuration"
2020-01-08 20:04:01 +00:00
}
2020-09-10 19:44:34 +00:00
function CONFIG__GIT() {
CONFIG__BASIC_SYMLINK "$HOME/.gitconfig" "$HOME/.wryn/config/git/gitconfig";
2020-09-10 19:52:16 +00:00
echo "linked global git configuration"
2020-09-10 19:44:34 +00:00
}
2020-09-10 19:38:42 +00:00
function CONFIG__PYLINT() {
CONFIG__BASIC_SYMLINK "$HOME/.config/pylintrc" "$HOME/.wryn/config/pylint/pylintrc";
echo "linked pylint configuration"
2020-04-02 18:40:26 +00:00
}
2020-09-10 19:38:42 +00:00
function CONFIG__TMUX() {
CONFIG__BASIC_SYMLINK "$HOME/.tmux.conf" "$HOME/.wryn/tmux/tmux.conf";
echo "linked tmux configuration"
}
2020-04-02 18:40:26 +00:00
2020-09-10 20:21:58 +00:00
function CONFIG__XINITRC() {
CONFIG__BASIC_SYMLINK "$HOME/.xinitrc" "$HOME/.wryn/config/xserver/xinitrc"
echo "linked xinitrc"
}
2020-09-10 19:38:42 +00:00
function CONFIG__TERMINFO() {
echo "adding terminfo files"
2020-01-23 23:04:49 +00:00
for file in $(find "$HOME/.wryn/config/terminfo" -type f); do
2020-09-10 19:38:42 +00:00
tic -x $file >/dev/null 2>&1 || echo "failed to add $file" ;
2020-01-23 23:04:49 +00:00
done
}
2020-09-10 19:38:42 +00:00
function CONFIG__SETUP() {
CONFIG__I3;
CONFIG__COMPTON;
CONFIG__KITTY;
2020-09-10 19:44:34 +00:00
CONFIG__GIT;
2020-09-10 19:38:42 +00:00
CONFIG__PYLINT;
CONFIG__TMUX;
2020-09-10 20:21:58 +00:00
CONFIG__XINITRC;
2020-09-10 19:38:42 +00:00
CONFIG__TERMINFO;
}
2020-09-10 19:52:16 +00:00
2020-09-10 19:38:42 +00:00
################################################################################
### RUN CONFIG #################################################################
################################################################################
2020-09-10 20:06:49 +00:00
function CLEAN_BACKUP() {
read -p "Clean backup files? [yN] : " yn;
case $yn in
[Yy]* )
echo 'cleaning backup files';
for file in $(find "$HOME/.config/" -name \*.bak); do rm $file; done
for file in $(find "$HOME" -name .\*.bak); do rm $file; done
;;
* ) echo 'skipping cleanup';;
esac
}
2020-09-10 19:52:16 +00:00
[ ! -d "$HOME/.config" ] && mkdir "$HOME/.config";
[ ! -d "$HOME/.config/wryn" ] && mkdir "$HOME/.config/wryn";
2020-09-10 19:38:42 +00:00
SHELL__SETUP;
VIM__SETUP;
CONFIG__SETUP;
2020-09-10 20:06:49 +00:00
CLEAN_BACKUP;
2020-09-10 19:38:42 +00:00
echo -e "\nsetup complete"