mirror of
https://github.com/aquatix/dotfiles.git
synced 2025-12-06 22:55:10 +01:00
Moved the link creation and backup into a function
This commit is contained in:
32
install.sh
32
install.sh
@@ -41,22 +41,15 @@ install_fish()
|
|||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the directory the dotfiles have been cloned into
|
make_link()
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
{
|
||||||
echo "Installing from $DIR"
|
DIR="$1"
|
||||||
DATETIME=$(date +%Y%m%d_%H%M)
|
TARGET="$2"
|
||||||
|
|
||||||
# Go home
|
|
||||||
cd || exit
|
|
||||||
|
|
||||||
# Symlink all the things
|
|
||||||
for TARGET in .bash_aliases .bashrc bin .gitconfig .gitmodules .hgauthors.txt .hgignore .hgrc .ignore .screenrc .terminfo .tmux.conf .vim .vimrc install.sh
|
|
||||||
do
|
|
||||||
cd || exit
|
cd || exit
|
||||||
echo $TARGET
|
echo $TARGET
|
||||||
if [ "$(readlink $TARGET)" = "$DIR/$TARGET" ]; then
|
if [ "$(readlink $TARGET)" = "$DIR/$TARGET" ]; then
|
||||||
echo " symlink exists and is fine, skipping"
|
echo " symlink exists and is fine, skipping"
|
||||||
continue
|
return
|
||||||
elif [ -e $TARGET ] || [ -L $TARGET ] && [ "$(readlink $TARGET)" != "$DIR/$TARGET" ]; then
|
elif [ -e $TARGET ] || [ -L $TARGET ] && [ "$(readlink $TARGET)" != "$DIR/$TARGET" ]; then
|
||||||
echo " exists, moving out of the way"
|
echo " exists, moving out of the way"
|
||||||
if [ ! -d "workspace/backup/dotfiles_$DATETIME" ]; then
|
if [ ! -d "workspace/backup/dotfiles_$DATETIME" ]; then
|
||||||
@@ -81,6 +74,21 @@ do
|
|||||||
# Create the symlink
|
# Create the symlink
|
||||||
ln -s "$DIR/$TARGET"
|
ln -s "$DIR/$TARGET"
|
||||||
#echo "ln -s $DIR/$TARGET"
|
#echo "ln -s $DIR/$TARGET"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the directory the dotfiles have been cloned into
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
echo "Installing from $DIR"
|
||||||
|
DATETIME=$(date +%Y%m%d_%H%M)
|
||||||
|
|
||||||
|
# Go home
|
||||||
|
cd || exit
|
||||||
|
|
||||||
|
# Symlink all the things
|
||||||
|
for TARGET in .bash_aliases .bashrc bin .gitconfig .gitmodules .hgauthors.txt .hgignore .hgrc .ignore .screenrc .terminfo .tmux.conf .vim .vimrc install.sh
|
||||||
|
do
|
||||||
|
make_link $DIR $TARGET
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "INFO: Init submodules"
|
echo "INFO: Init submodules"
|
||||||
|
|||||||
Reference in New Issue
Block a user