Created
April 30, 2021 17:45
-
-
Save engineervix/d9cef5adb520b6c2f2ee0e01e5280f1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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