302 lines
7.8 KiB
Bash
Executable File
302 lines
7.8 KiB
Bash
Executable File
#!/usr/bin/zsh
|
|
|
|
################################################################################
|
|
### SETUP VERIFICATION #########################################################
|
|
################################################################################
|
|
|
|
DOTWRYN_PATH="$(pwd)"
|
|
function CHECK_DIR() {
|
|
printf "is DOTWRYN.git installed at '$DOTWRYN_PATH'? [Yn] : "
|
|
local yn; read yn
|
|
|
|
[[ $yn =~ ^[nN] ]] && return 1 || return 0
|
|
}
|
|
|
|
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
|
|
|
|
|
|
################################################################################
|
|
### SHELL SETUP ################################################################
|
|
################################################################################
|
|
|
|
function SOURCE_DOTWRYN_RC {
|
|
local HOME_RC="$1";
|
|
local WRYN_RC="$2";
|
|
|
|
[ ! -f "$HOME/$HOME_RC" ] && touch "$HOME/$HOME_RC";
|
|
|
|
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() {
|
|
local yn
|
|
|
|
local DEFAULT_SHELL_ENV="$DOTWRYN_PATH/env/env"
|
|
local LOCAL_SHELL_ENV="$HOME/.config/wryn/env/env"
|
|
|
|
[ $LOCAL_SHELL_ENV ] && {
|
|
printf 'local env override file detected; overwrite? [yN] : '
|
|
read $yn
|
|
[[ $yn =~ ^[yY] ]] || DO_NOT_OVERWRITE_SHELL=1
|
|
}
|
|
|
|
[ $DO_NOT_OVERWRITE_SHELL ] && echo 'skipping shell env setup' || {
|
|
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"
|
|
}
|
|
|
|
local DEFAULT_VIM_ENV="$DOTWRYN_PATH/env/env.vim"
|
|
local LOCAL_VIM_ENV="$HOME/.config/wryn/env/env.vim"
|
|
|
|
[ $LOCAL_SHELL_ENV ] && {
|
|
printf 'local vim env override file detected; overwrite? [yN] : '
|
|
read $yn
|
|
[[ $yn =~ ^[yY] ]] || DO_NOT_OVERWRITE_VIM=1
|
|
}
|
|
|
|
[ $DO_NOT_OVERWRITE_VIM ] && echo 'skipping vim env setup' || {
|
|
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"
|
|
}
|
|
}
|
|
|
|
function SHELL__SETUP {
|
|
SOURCE_DOTWRYN_RC '.bashrc' "$DOTWRYN_PATH/zsh/rc";
|
|
SOURCE_DOTWRYN_RC '.zshrc' "$DOTWRYN_PATH/zsh/rc";
|
|
|
|
ENV__SETUP_LOCAL_OVERRIDES;
|
|
}
|
|
|
|
|
|
################################################################################
|
|
### VIM SETUP ##################################################################
|
|
################################################################################
|
|
|
|
function VIM__UPDATE_COLORSCHEMES() {
|
|
$DOTWRYN_PATH/bin/vim/update_colorschemes
|
|
}
|
|
|
|
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;
|
|
|
|
echo "building plugins"
|
|
$DOTWRYN_PATH/bin/vim/rebuild_plugins;
|
|
}
|
|
|
|
function VIM__SETUP() {
|
|
echo 'setting up vim';
|
|
|
|
SOURCE_DOTWRYN_RC '.vimrc' "$DOTWRYN_PATH/vim/rc.vim";
|
|
|
|
VIM__UPDATE_COLORSCHEMES;
|
|
VIM__INSTALL_VUNDLE_PLUGINS;
|
|
|
|
echo 'vim setup complete';
|
|
}
|
|
|
|
|
|
################################################################################
|
|
### LINK CONFIGURATION FILES ###################################################
|
|
################################################################################
|
|
|
|
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="$DOTWRYN_PATH/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";
|
|
CONFIG__BASIC_SYMLINK "$HOME/.config/wryn/i3utils" "$DOTWRYN_PATH/config/i3/utils";
|
|
echo "linked i3 configuration";
|
|
}
|
|
|
|
function CONFIG__I3STATUS() {
|
|
CONFIG__SYMLINK "i3status" "config";
|
|
echo "linked i3status configuration";
|
|
}
|
|
|
|
function CONFIG__PGCLI() {
|
|
CONFIG__SYMLINK "pgcli" "config";
|
|
echo "linked pgcli configuration";
|
|
}
|
|
|
|
function CONFIG__MSSQLCLI() {
|
|
CONFIG__SYMLINK "mssqlcli" "config";
|
|
echo "linked mssqlcli 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"
|
|
}
|
|
|
|
function CONFIG__RIPGREP() {
|
|
CONFIG__SYMLINK "ripgrep" "config"
|
|
echo "linked ripgrep configuration"
|
|
}
|
|
|
|
function CONFIG__GIT() {
|
|
CONFIG__BASIC_SYMLINK "$HOME/.gitconfig" "$DOTWRYN_PATH/config/git/gitconfig";
|
|
echo "linked global git configuration"
|
|
}
|
|
|
|
function CONFIG__PYLINT() {
|
|
CONFIG__BASIC_SYMLINK "$HOME/.config/pylintrc" "$DOTWRYN_PATH/config/pylint/pylintrc";
|
|
echo "linked pylint configuration"
|
|
}
|
|
|
|
function CONFIG__SFX_APPLICATION() {
|
|
CONFIG__BASIC_SYMLINK "$HOME/.config/wryn/sfx" "$DOTWRYN_PATH/bin/desktop/sfx/play.sh";
|
|
echo "linked xinitrc"
|
|
}
|
|
|
|
function CONFIG__TMUX() {
|
|
CONFIG__BASIC_SYMLINK "$HOME/.tmux.conf" "$DOTWRYN_PATH/config/tmux/tmux.conf";
|
|
echo "linked tmux configuration"
|
|
}
|
|
|
|
function CONFIG__XINITRC() {
|
|
CONFIG__BASIC_SYMLINK "$HOME/.xinitrc" "$DOTWRYN_PATH/config/xorg/xinitrc"
|
|
echo "linked xinitrc"
|
|
}
|
|
|
|
|
|
function CONFIG__TERMINFO() {
|
|
echo "adding terminfo files"
|
|
for file in $(find "$DOTWRYN_PATH/config/terminfo" -type f); do
|
|
tic -x $file >/dev/null 2>&1 || echo "failed to add $file" ;
|
|
done
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
|
|
function CONFIG__SETUP() {
|
|
CONFIG__I3;
|
|
CONFIG__I3STATUS;
|
|
CONFIG__PGCLI;
|
|
CONFIG__MSSQLCLI;
|
|
CONFIG__COMPTON;
|
|
CONFIG__KITTY;
|
|
CONFIG__RIPGREP;
|
|
|
|
CONFIG__GIT;
|
|
CONFIG__PYLINT;
|
|
CONFIG__SFX_APPLICATION;
|
|
CONFIG__TMUX;
|
|
CONFIG__XINITRC;
|
|
|
|
CONFIG__TERMINFO;
|
|
|
|
|
|
CLEAN_BACKUP
|
|
}
|
|
|
|
|
|
################################################################################
|
|
### RUN CONFIG #################################################################
|
|
################################################################################
|
|
|
|
|
|
[ ! -d "$HOME/.config" ] && mkdir "$HOME/.config";
|
|
[ ! -d "$HOME/.config/wryn" ] && mkdir "$HOME/.config/wryn";
|
|
[ ! -d "$HOME/.config/wryn/env" ] && mkdir "$HOME/.config/wryn/env";
|
|
|
|
SHELL__SETUP
|
|
#VIM__SETUP
|
|
#CONFIG__SETUP
|
|
|
|
echo -e "\nsetup complete"
|