dotwryn/setup

302 lines
7.8 KiB
Plaintext
Raw Normal View History

2021-06-28 17:24:34 +00:00
#!/usr/bin/zsh
2021-02-25 00:38:02 +00:00
################################################################################
### SETUP VERIFICATION #########################################################
################################################################################
DOTWRYN_PATH="$(pwd)"
function CHECK_DIR() {
2021-06-28 17:24:34 +00:00
printf "is DOTWRYN.git installed at '$DOTWRYN_PATH'? [Yn] : "
local yn; read yn
2021-02-25 00:38:02 +00:00
2021-06-28 17:24:34 +00:00
[[ $yn =~ ^[nN] ]] && return 1 || return 0
2021-02-25 00:38:02 +00:00
}
2021-06-28 17:24:34 +00:00
function INSTALL_DEPENDENCIES() {
local OS_NAME=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
local GENERIC_DEPS=(python3 cmake lolcat figlet cowsay)
local ARCH_DEPS=(python cmake lolcat figlet cowsay)
local DEBIAN_DEPS=(python3-dev cmake lolcat figlet cowsay)
MISSING_DEPS=()
echo 'checking dependencies...'
for DEP in $GENERIC_DEPS;
do
command -v $DEP >/dev/null 2>&1 || {
echo "missing '$DEP'"
MISSING_DEPS+=$DEP
}
done
[[ ${#MISSING_DEPS[@]} -eq 0 ]] && {
echo '...all dependencies appear to be satisfied'
} || {
case $OS_NAME in
arch )
sudo pacman -Syu $ARCH_DEPS
;;
debian | ubuntu )
sudo apt-get install $DEBIAN_DEPS
;;
* )
echo "manual dependency installation required for os '$OS_NAME'..."
echo "missing : $MISSING_DEPS"
printf 'are you ready to proceed with setup? [yN] : '
local yn; read yn
[[ $yn =~ ^[yY] ]] && return 0 || return 1
;;
esac
}
}
CHECK_DIR || exit 1
INSTALL_DEPENDENCIES || exit 1
2021-02-25 00:38:02 +00:00
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";
2021-02-25 00:38:02 +00:00
grep "$WRYN_RC" "$HOME/$HOME_RC" && {
echo "already set up $HOME_RC";
} || {
echo "source $WRYN_RC" >> "$HOME/$HOME_RC";
echo "successfully set up $HOME_RC";
}
}
function ENV__SETUP_LOCAL_OVERRIDES() {
2021-06-28 17:24:34 +00:00
local yn
2021-02-25 00:38:02 +00:00
local DEFAULT_SHELL_ENV="$DOTWRYN_PATH/env/env"
local LOCAL_SHELL_ENV="$HOME/.config/wryn/env/env"
2021-06-28 17:24:34 +00:00
[ $LOCAL_SHELL_ENV ] && {
printf 'local env override file detected; overwrite? [yN] : '
2021-09-15 03:11:17 +00:00
read yn
2021-06-28 17:24:34 +00:00
[[ $yn =~ ^[yY] ]] || DO_NOT_OVERWRITE_SHELL=1
}
2021-09-15 03:11:17 +00:00
[[ $DO_NOT_OVERWRITE_SHELL -eq 1 ]] && echo 'skipping shell env setup' || {
2021-06-28 17:24:34 +00:00
echo "source $DOTWRYN_PATH/env/env" > "$LOCAL_SHELL_ENV"
echo -e '\n#\n# ~/.wryn/env/env local overrides\n#\n' >> "$LOCAL_SHELL_ENV"
sed 's/[#]*\(.*\)/#\1/' $DEFAULT_SHELL_ENV >> "$LOCAL_SHELL_ENV"
}
2021-02-25 00:38:02 +00:00
local DEFAULT_VIM_ENV="$DOTWRYN_PATH/env/env.vim"
local LOCAL_VIM_ENV="$HOME/.config/wryn/env/env.vim"
2021-06-28 17:24:34 +00:00
[ $LOCAL_SHELL_ENV ] && {
printf 'local vim env override file detected; overwrite? [yN] : '
2021-09-15 03:11:17 +00:00
read yn
2021-06-28 17:24:34 +00:00
[[ $yn =~ ^[yY] ]] || DO_NOT_OVERWRITE_VIM=1
}
2021-02-25 00:38:02 +00:00
2021-09-15 03:11:17 +00:00
[[ $DO_NOT_OVERWRITE_VIM -eq 1 ]] && echo 'skipping vim env setup' || {
2021-06-28 17:24:34 +00:00
echo "source $DOTWRYN_PATH/env/env.vim" > "$LOCAL_VIM_ENV"
echo -e '\n"\n" ~/.wryn/env/env.vim local overrides\n"\n' >> "$LOCAL_VIM_ENV"
sed 's/["]*\(.*\)/"\1/' $DEFAULT_VIM_ENV >> "$LOCAL_VIM_ENV"
}
2020-09-10 19:38:42 +00:00
}
2020-09-10 19:38:42 +00:00
function SHELL__SETUP {
2021-02-25 00:38:02 +00:00
SOURCE_DOTWRYN_RC '.bashrc' "$DOTWRYN_PATH/zsh/rc";
SOURCE_DOTWRYN_RC '.zshrc' "$DOTWRYN_PATH/zsh/rc";
2021-02-25 00:38:02 +00:00
ENV__SETUP_LOCAL_OVERRIDES;
2020-09-10 19:38:42 +00:00
}
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__UPDATE_COLORSCHEMES() {
2021-02-25 00:38:02 +00:00
$DOTWRYN_PATH/bin/vim/update_colorschemes
2020-09-10 19:38:42 +00:00
}
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"
2021-02-25 00:38:02 +00:00
$DOTWRYN_PATH/bin/vim/rebuild_plugins;
2020-09-10 19:38:42 +00:00
}
function VIM__SETUP() {
echo 'setting up vim';
2021-02-25 00:38:02 +00:00
SOURCE_DOTWRYN_RC '.vimrc' "$DOTWRYN_PATH/vim/rc.vim";
2020-09-10 19:38:42 +00:00
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";
2020-09-23 22:19:23 +00:00
mv "$HOME_CONFIG" "$HOME_CONFIG.bak" >/dev/null 2>&1;
2020-09-10 19:38:42 +00:00
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";
2021-02-25 00:38:02 +00:00
local WRYN_CONFIG="$DOTWRYN_PATH/config/$CONFIG_DIR/$FILENAME";
2020-09-10 19:38:42 +00:00
[ ! -d "$HOME_CONFIG_DIR" ] && mkdir "$HOME_CONFIG_DIR";
CONFIG__BASIC_SYMLINK $HOME_CONFIG $WRYN_CONFIG;
}
function CONFIG__I3() {
CONFIG__SYMLINK "i3" "config";
2021-02-25 00:38:02 +00:00
CONFIG__BASIC_SYMLINK "$HOME/.config/wryn/i3utils" "$DOTWRYN_PATH/config/i3/utils";
2020-09-23 22:19:23 +00:00
echo "linked i3 configuration";
2020-09-10 19:38:42 +00:00
}
2021-02-24 01:34:12 +00:00
function CONFIG__I3STATUS() {
CONFIG__SYMLINK "i3status" "config";
echo "linked i3status configuration";
}
2020-09-17 19:23:10 +00:00
function CONFIG__PGCLI() {
CONFIG__SYMLINK "pgcli" "config";
echo "linked pgcli configuration";
}
function CONFIG__MSSQLCLI() {
2020-09-17 19:23:10 +00:00
CONFIG__SYMLINK "mssqlcli" "config";
echo "linked mssqlcli configuration";
}
2020-09-10 19:38:42 +00:00
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
}
2021-02-25 00:38:02 +00:00
function CONFIG__RIPGREP() {
CONFIG__SYMLINK "ripgrep" "config"
echo "linked ripgrep configuration"
}
2020-09-10 19:44:34 +00:00
function CONFIG__GIT() {
2021-02-25 00:38:02 +00:00
CONFIG__BASIC_SYMLINK "$HOME/.gitconfig" "$DOTWRYN_PATH/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() {
2021-02-25 00:38:02 +00:00
CONFIG__BASIC_SYMLINK "$HOME/.config/pylintrc" "$DOTWRYN_PATH/config/pylint/pylintrc";
2020-09-10 19:38:42 +00:00
echo "linked pylint configuration"
2020-04-02 18:40:26 +00:00
}
2021-02-25 01:03:59 +00:00
function CONFIG__SFX_APPLICATION() {
CONFIG__BASIC_SYMLINK "$HOME/.config/wryn/sfx" "$DOTWRYN_PATH/bin/desktop/sfx/play.sh";
echo "linked xinitrc"
}
2020-09-10 19:38:42 +00:00
function CONFIG__TMUX() {
2021-02-25 00:38:02 +00:00
CONFIG__BASIC_SYMLINK "$HOME/.tmux.conf" "$DOTWRYN_PATH/config/tmux/tmux.conf";
2020-09-10 19:38:42 +00:00
echo "linked tmux configuration"
}
2020-04-02 18:40:26 +00:00
2020-09-10 20:21:58 +00:00
function CONFIG__XINITRC() {
2021-02-25 00:38:02 +00:00
CONFIG__BASIC_SYMLINK "$HOME/.xinitrc" "$DOTWRYN_PATH/config/xorg/xinitrc"
2020-09-10 20:21:58 +00:00
echo "linked xinitrc"
}
2021-02-25 01:03:59 +00:00
2020-09-10 19:38:42 +00:00
function CONFIG__TERMINFO() {
echo "adding terminfo files"
2021-02-25 00:38:02 +00:00
for file in $(find "$DOTWRYN_PATH/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
2021-06-28 17:24:34 +00:00
function CLEAN_BACKUP() {
read -p "clean backup files? [Yn] : " yn;
case $yn in
[nN]* ) echo 'skipping cleanup';;
* )
echo 'cleaning backup files';
for file in $(find "$HOME/.config/" -name \*.bak 2>/dev/null); do rm $file && echo cleaned $file; done
for file in $(find "$HOME" -maxdepth 1 -name .\*.bak 2>/dev/null); do rm $file && echo cleaned $file; done
;;
esac
}
2020-09-10 19:38:42 +00:00
2020-09-10 19:38:42 +00:00
function CONFIG__SETUP() {
CONFIG__I3;
2021-02-24 01:34:12 +00:00
CONFIG__I3STATUS;
2020-09-17 19:23:10 +00:00
CONFIG__PGCLI;
CONFIG__MSSQLCLI;
2020-09-10 19:38:42 +00:00
CONFIG__COMPTON;
CONFIG__KITTY;
2021-02-25 00:38:02 +00:00
CONFIG__RIPGREP;
2020-09-10 19:38:42 +00:00
2020-09-10 19:44:34 +00:00
CONFIG__GIT;
2020-09-10 19:38:42 +00:00
CONFIG__PYLINT;
2021-02-25 01:03:59 +00:00
CONFIG__SFX_APPLICATION;
2020-09-10 19:38:42 +00:00
CONFIG__TMUX;
2020-09-10 20:21:58 +00:00
CONFIG__XINITRC;
2020-09-10 19:38:42 +00:00
CONFIG__TERMINFO;
2021-06-28 17:24:34 +00:00
CLEAN_BACKUP
2020-09-10 19:38:42 +00:00
}
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
2020-09-10 19:52:16 +00:00
[ ! -d "$HOME/.config" ] && mkdir "$HOME/.config";
[ ! -d "$HOME/.config/wryn" ] && mkdir "$HOME/.config/wryn";
2021-02-25 00:38:02 +00:00
[ ! -d "$HOME/.config/wryn/env" ] && mkdir "$HOME/.config/wryn/env";
2020-09-10 19:52:16 +00:00
2021-06-28 17:24:34 +00:00
SHELL__SETUP
2021-09-15 03:11:17 +00:00
VIM__SETUP
CONFIG__SETUP
2020-09-10 20:06:49 +00:00
2020-09-10 19:38:42 +00:00
echo -e "\nsetup complete"