mirror of
https://github.com/bertptrs/vimconfig.git
synced 2025-12-25 20:40:32 +01:00
Improve installation script.
This commit is contained in:
65
install.sh
65
install.sh
@@ -6,29 +6,30 @@ commandAvailable() {
|
||||
command -v $1 >/dev/null
|
||||
}
|
||||
|
||||
confirm () {
|
||||
# call with a prompt string or use a default
|
||||
read -r -p "${1:-Are you sure? [y/N]} " response
|
||||
case $response in
|
||||
[yY][eE][sS]|[yY])
|
||||
true
|
||||
;;
|
||||
*)
|
||||
false
|
||||
;;
|
||||
esac
|
||||
}
|
||||
installIfAvailable() {
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 command_required [package_name]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
confirmAndLink() {
|
||||
if [ -e $2 ]
|
||||
then
|
||||
echo "Destination $2 already exists and will be overwritten."
|
||||
confirm && rm -rf $2 && ln -s $1 $2
|
||||
COMMAND=$1
|
||||
if [ $# -eq 2 ]; then
|
||||
PACKAGE=$2
|
||||
else
|
||||
ln -s $1 $2
|
||||
PACKAGE=$COMMAND
|
||||
fi
|
||||
|
||||
if commandAvailable $COMMAND; then
|
||||
echo "Installing configuration files for $COMMAND…"
|
||||
stow -t $HOME $PACKAGE
|
||||
fi
|
||||
}
|
||||
|
||||
if ! commandAvailable stow; then
|
||||
echo "Error: stow not available. Skipping installation." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd $DIR && echo "Current working directory is ${DIR}"
|
||||
|
||||
echo -n "Downloading dependencies... "
|
||||
@@ -38,34 +39,14 @@ git submodule init &> /dev/null && git submodule update &> /dev/null \
|
||||
|
||||
echo "done."
|
||||
|
||||
if ! commandAvailable stow; then
|
||||
echo "Error: stow not available. Skipping installation." >&2;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Install vim
|
||||
|
||||
if commandAvailable vim
|
||||
then
|
||||
echo "Installing configuration files for vim.";
|
||||
stow -t $HOME vim
|
||||
fi
|
||||
|
||||
# Install zsh, if relevant.
|
||||
if commandAvailable zsh
|
||||
then
|
||||
echo "Installing configuration files for zsh."
|
||||
stow -t $HOME zsh
|
||||
fi
|
||||
|
||||
if commandAvailable "sqlite3"
|
||||
then
|
||||
echo "Installing configuration files for sqlite."
|
||||
stow -t $HOME sqlite
|
||||
fi
|
||||
installIfAvailable vim
|
||||
installIfAvailable zsh
|
||||
installIfAvailable sqlite3 sqlite
|
||||
|
||||
# Install all XDG compatible packages
|
||||
echo "Installing remaining packages"
|
||||
echo "Installing remaining packages…"
|
||||
stow -t $HOME pacman git
|
||||
|
||||
echo "Installation finished."
|
||||
|
||||
Reference in New Issue
Block a user