mirror of
https://github.com/AquaMorph/dotfiles.git
synced 2025-04-29 17:25:34 +00:00
Install script uses functions
This commit is contained in:
parent
8550832516
commit
c0ae64ccfb
@ -24,37 +24,57 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo Setting up dotfiles...
|
# Check emacs setup
|
||||||
|
function emacs {
|
||||||
# Loop through config files
|
if ! [ -d ~/.emacs.d ]; then
|
||||||
for (( i=0; i<${#files[@]} ; i+=3 )) ; do
|
echo Installing emacs config
|
||||||
# Check if sudo is needed
|
cd ~
|
||||||
pre=''
|
git clone git@github.com:AquaMorph/.emacs.d.git
|
||||||
if [[ ${files[i+2]} == *'y'* ]]; then
|
|
||||||
if [ $noRoot ]; then
|
|
||||||
echo Skipping ${files[i]} because root is required
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
pre='sudo'
|
|
||||||
fi
|
|
||||||
|
|
||||||
destPath=${files[i+1]}$(basename "${files[i]}")
|
|
||||||
|
|
||||||
# Check if file already exists
|
|
||||||
if [ -e $destPath ]; then
|
|
||||||
# Check if path is not a sybolic link
|
|
||||||
if ! [ -L $destPath ]; then
|
|
||||||
echo Backing up $destPath
|
|
||||||
$pre mv $destPath ${destPath}.bak
|
|
||||||
# File already set up
|
|
||||||
else
|
|
||||||
echo The file $destPath is already set up
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# Create missing directories
|
|
||||||
else
|
else
|
||||||
$pre mkdir -p "$(dirname "$destPath")"
|
echo Checking for emacs config updates
|
||||||
|
cd ~/.emacs.d
|
||||||
|
git pull
|
||||||
fi
|
fi
|
||||||
echo Creating symbolic link from ${files[i]} to ${files[i+1]}
|
|
||||||
$pre ln -sf ${files[i]} ${files[i+1]}
|
}
|
||||||
done
|
|
||||||
|
# Check managed dotfiles
|
||||||
|
function dotfiles {
|
||||||
|
echo Setting up dotfiles...
|
||||||
|
|
||||||
|
# Loop through config files
|
||||||
|
for (( i=0; i<${#files[@]} ; i+=3 )) ; do
|
||||||
|
# Check if sudo is needed
|
||||||
|
pre=''
|
||||||
|
if [[ ${files[i+2]} == *'y'* ]]; then
|
||||||
|
if [ $noRoot ]; then
|
||||||
|
echo Skipping ${files[i]} because root is required
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
pre='sudo'
|
||||||
|
fi
|
||||||
|
|
||||||
|
destPath=${files[i+1]}$(basename "${files[i]}")
|
||||||
|
|
||||||
|
# Check if file already exists
|
||||||
|
if [ -e $destPath ]; then
|
||||||
|
# Check if path is not a sybolic link
|
||||||
|
if ! [ -L $destPath ]; then
|
||||||
|
echo Backing up $destPath
|
||||||
|
$pre mv $destPath ${destPath}.bak
|
||||||
|
# File already set up
|
||||||
|
else
|
||||||
|
echo The file $destPath is already set up
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Create missing directories
|
||||||
|
else
|
||||||
|
$pre mkdir -p "$(dirname "$destPath")"
|
||||||
|
fi
|
||||||
|
echo Creating symbolic link from ${files[i]} to ${files[i+1]}
|
||||||
|
$pre ln -sf ${files[i]} ${files[i+1]}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
dotfiles
|
||||||
|
emacs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user