dotfiles/setup.sh
2022-04-02 16:02:55 +02:00

68 lines
1.8 KiB
Bash
Executable file

#!/bin/bash
set -u
mkdir -p ~/.config/homedir-backup 2>/dev/null
function linkfiles {
for file in $@; do
name=$(basename $file)
dir=$(dirname $file)
if [ "$dir" == "dotfiles" ] ; then
targetdir=""
elif [ "$( dirname $dir | cut -f1 -d/)" == "configfile" ] ; then
targetdir="config/$(echo $dir | cut -f2- -d/)/"
mkdir -p "${HOME}/.${targetdir}"
else
targetdir="$dir/"
fi
if [ -f hosts/$(hostname -s)/${name} ] ; then
dotfile="$(pwd)/hosts/$(hostname -s)/${name}"
else
dotfile="$(pwd)/$dir/${name}"
fi
# Backup local dotfiles:
if [ ! -L ~/.${targetdir}${name} ] ; then
mv -v "${HOME}/.${targetdir}${name}" ~/.config/homedir-backup
fi
# Fix broken links
if [ -L ~/.${targetdir}${name} ] ; then
rm -f "${HOME}/.${targetdir}${name}"
fi
ln -s "$dotfile" "${HOME}/.${targetdir}${name}"
done
}
linkfiles 'dotfiles/*'
#git clone https://github.com/NvChad/NvChad ~/.config/nvim
#nvim -c "autocmd User PackerComplete quitall" -c "PackerSync"
#linkfiles 'config/*'
set -x
for file in $(find configfile -type f) ; do
linkfiles $file
done
set +x
exit
# Install powerline if possible
if which pip3 ; then
pip3 install --user -U -r requirements.txt
else
[ ! -d ~/.bash-git-prompt ] && git clone https://github.com/nold360/bash-git-prompt.git ~/.bash-git-prompt
fi
# Install vundle plugin manager & plugins
mkdir -p ~/.vim/bundle 2>/dev/null
[ ! -d ~/.vim/bundle/Vundle.vim ] && git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim -c ":PluginInstall" -c ":q" -c ":q"
# Tmux Plugin Manager
mkdir -p ~/.tmux/plugins 2>/dev/null
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
grep -qE "^source.*$(pwd)/bashrc" ~/.bashrc || echo "source $(pwd)/bashrc" >> ~/.bashrc
echo Done