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