Skip to content

Instantly share code, notes, and snippets.

@engineervix
Created April 30, 2021 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save engineervix/d9cef5adb520b6c2f2ee0e01e5280f1e to your computer and use it in GitHub Desktop.
Save engineervix/d9cef5adb520b6c2f2ee0e01e5280f1e to your computer and use it in GitHub Desktop.
#!/bin/bash
function die()
{
echo "${@}"
exit 1
}
function backup_previous_install()
{
# Add .old to any existing Vim file in the home directory
for filepath in "${HOME}/.vim" "${HOME}/.vimrc" "${HOME}/.gvimrc"; do
if [ -e $filepath ]; then
mv "${filepath}" "${filepath}.old" || die "Could not move ${filepath} to ${filepath}.old"
echo "${filepath} has been renamed to ${filepath}.old"
fi
done
}
function clone_janus()
{
# Clone Janus into .vim
git clone --recursive https://github.com/carlhuda/janus.git "${HOME}/.vim" \
|| die "Could not clone the repository to ${HOME}/.vim"
}
function run_rake()
{
# Run rake inside .vim
pushd "${HOME}/.vim" || die "Could not go into the ${HOME}/.vim"
rake || die "Rake failed."
# popd
}
function main()
{
if [ ! -e "${HOME}/.vim/janus" -o "$1" == "--force" ]; then
backup_previous_install
clone_janus
fi
run_rake
}
main $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment