2020-12-13 06:12:28 +00:00
#!/bin/bash
# This script sets up the configuration from this repository
DIR = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " >/dev/null 2>& 1 && pwd ) "
2020-12-14 06:25:39 +00:00
APT = ` command -v apt`
DNF = ` command -v dnf`
2020-12-13 06:12:28 +00:00
2020-12-14 22:19:44 +00:00
function check_or_install( ) {
2020-12-14 06:25:39 +00:00
CMD = ` command -v $1 `
PKG = $2
if [ [ -z " $CMD " ] ] ; then
if [ [ -n " $APT " ] ] ; then
sudo apt install -y $PKG
elif [ [ -n " $DNF " ] ] ; then
sudo dnf install -y $PKG
fi
fi
}
2023-07-07 18:50:30 +00:00
function install_build_tools( ) {
if [ [ " ${ APT } x " = = "x" ] ] ; then
# This is not Debian
return
fi
echo "Installing build tools..."
check_or_install gcc build-essential
}
2020-12-14 22:19:44 +00:00
function setup_neovim( ) {
# Set up Neovim
if [ [ -d " $HOME /.config/nvim " ] ] ; then
return
fi
echo "Setting up neovim..."
check_or_install nvim "neovim python3-neovim"
cd $HOME /.config
ln -s $DIR /nvim
curl -fLo " ${ XDG_DATA_HOME :- $HOME /.local/share } " /nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
2023-07-07 18:50:30 +00:00
nvim --headless +PlugInstall +qa
nvim +UpdateRemotePlugins +qa
2020-12-14 22:19:44 +00:00
}
function setup_git( ) {
# Set up Git
echo "Setting up git..."
check_or_install git git
git config --global alias.co checkout
git config --global alias.ci "commit -a"
git config --global alias.st status
git config --global alias.br "checkout -b"
git config --global alias.rv "reset --hard HEAD"
git config --global alias.pum "pull upstream master"
git config --global alias.pom "push origin master"
git config --global alias.rbm "rebase master"
git config --global alias.last "log -1 HEAD"
git config --global alias.unstage "reset HEAD --"
git config --global alias.uncommit "reset --soft HEAD^"
git config --global alias.changelog "!_() { t=\$(git describe --abbrev=0 --tags); git log \${t}..HEAD --no-merges --pretty=format:'* %s'; }; _"
git config --global pull.rebase false
}
function setup_zsh( ) {
# Set up ZSH
2023-07-07 18:50:30 +00:00
if [ [ -d " $HOME /.zprezto " ] ] ; then
2020-12-14 22:19:44 +00:00
return
fi
echo "Setting up zsh..."
check_or_install zsh zsh
2023-07-07 18:50:30 +00:00
git clone --recursive https://github.com/sorin-ionescu/prezto.git " ${ ZDOTDIR :- $HOME } /.zprezto "
if [ [ -f " $HOME /.zshrc " ] ] ; then
mv " $HOME /.zshrc " " $HOME /.zshrc.original "
fi
zsh -c 'setopt EXTENDED_GLOB; for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"; done'
cd $HOME
patch -p0 < $DIR /zsh/prezto.diff
2020-12-14 22:19:44 +00:00
}
function setup_topydo( ) {
# Set up topydo
if [ [ -d " $HOME /.topydo " ] ] ; then
return
fi
echo "Set up topydo (as 'todo')..."
2021-09-12 03:28:13 +00:00
check_or_install virtualenv "virtualenv python3-virtualenv"
2020-12-14 22:19:44 +00:00
cd $HOME /.config
ln -s $DIR /topydo
virtualenv -p python3 $HOME /.topydo
$HOME /.topydo/bin/pip install topydo
$HOME /.topydo/bin/pip install 'topydo[prompt]'
$HOME /.topydo/bin/pip install 'topydo[columns]'
cd $HOME /bin
ln -s $HOME /.topydo/bin/topydo
ln -s $HOME /.topydo/bin/topydo todo
}
2020-12-14 18:38:35 +00:00
# Set up a generic bin directory for scripts and tools
2020-12-14 22:19:44 +00:00
mkdir -p $HOME /bin
mkdir -p $HOME /.config
2023-07-07 18:50:30 +00:00
install_build_tools
2020-12-14 22:19:44 +00:00
setup_neovim
setup_git
setup_zsh
2023-07-07 18:50:30 +00:00
# Not used anymore
# setup_topydo