Fix: Setup.sh
This commit is contained in:
parent
4c3e8d019a
commit
a92b6b21de
1 changed files with 18 additions and 16 deletions
22
setup.sh
22
setup.sh
|
@ -4,36 +4,38 @@ mkdir -p ~/.config/homedir-backup 2>/dev/null
|
||||||
|
|
||||||
function linkfiles {
|
function linkfiles {
|
||||||
for file in $@; do
|
for file in $@; do
|
||||||
create_dir=false
|
|
||||||
name=$(basename $file)
|
name=$(basename $file)
|
||||||
dir=$(dirname $file)
|
dir=$(dirname $file)
|
||||||
if [ "$dir" == "dotfiles" ] ; then
|
if [ "$dir" == "dotfiles" ] ; then
|
||||||
targetdir=""
|
targetdir=""
|
||||||
elif [ "$( dirname $dir | cut -f1 -d/)" == "configfile" ] ; then
|
elif [ "$( dirname $dir | cut -f1 -d/)" == "configfile" ] ; then
|
||||||
targetdir="config/$(echo $dir | cut -f2- -d/)/"
|
targetdir="config/$(echo $dir | cut -f2- -d/)/"
|
||||||
create_dir=true
|
mkdir -p "${HOME}/.${targetdir}"
|
||||||
else
|
else
|
||||||
targetdir="$dir/"
|
targetdir="$dir/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -L ~/.${targetdir}${name} ] ; then
|
|
||||||
if $create_dir ; then
|
|
||||||
mkdir -p ~/.${targetdir}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f hosts/$(hostname -s)/${name} ] ; then
|
if [ -f hosts/$(hostname -s)/${name} ] ; then
|
||||||
dotfile="$(pwd)/hosts/$(hostname -s)/${name}"
|
dotfile="$(pwd)/hosts/$(hostname -s)/${name}"
|
||||||
else
|
else
|
||||||
dotfile="$(pwd)/$dir/${name}"
|
dotfile="$(pwd)/$dir/${name}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv -v ~/.${targetdir}${name} ~/.config/homedir-backup
|
# Backup local dotfiles:
|
||||||
ln -s "$dotfile" ~/.${targetdir}${name}
|
if [ ! -L ~/.${targetdir}${name} ] ; then
|
||||||
|
mv -v "${HOME}/.${targetdir}${name}" ~/.config/homedir-backup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Fix broken links
|
||||||
|
if [ -L ~/.${targetdir}${name} ] ; then
|
||||||
|
rm -f "${HOME}/.${targetdir}${name}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -s "$dotfile" "${HOME}/.${targetdir}${name}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
#linkfiles 'dotfiles/*'
|
linkfiles 'dotfiles/*'
|
||||||
|
|
||||||
#git clone https://github.com/NvChad/NvChad ~/.config/nvim
|
#git clone https://github.com/NvChad/NvChad ~/.config/nvim
|
||||||
#nvim -c "autocmd User PackerComplete quitall" -c "PackerSync"
|
#nvim -c "autocmd User PackerComplete quitall" -c "PackerSync"
|
||||||
|
|
Loading…
Reference in a new issue