2016-08-01 21:30:21 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-08-01 21:36:36 +02:00
|
|
|
# This script toggles between local vim and a version that can be stored on an
|
|
|
|
# external device like a USB.
|
2016-08-01 21:30:21 +02:00
|
|
|
|
|
|
|
if [ -L "$HOME/.vim" ]; then
|
2016-08-01 21:36:36 +02:00
|
|
|
echo "Pointing to USB. Toggling back to local machine..."
|
2016-08-01 21:30:21 +02:00
|
|
|
|
|
|
|
# remove the symlink and .vimrc
|
|
|
|
rm "$HOME/.vim"
|
|
|
|
|
|
|
|
# remove the USB's version of the .vimrc and use the backed-up copy
|
|
|
|
rm "$HOME/.vimrc"
|
|
|
|
mv "$HOME/.vimrc.bak" "$HOME/.vimrc"
|
|
|
|
|
|
|
|
# rename the .vim.bak directory
|
|
|
|
mv "$HOME/.vim.bak" "$HOME/.vim"
|
|
|
|
|
|
|
|
echo ".vim now points to $HOME/.vim"
|
|
|
|
else
|
2016-08-01 21:36:36 +02:00
|
|
|
echo "Pointing to local machine. Toggling to USB..."
|
2016-08-01 21:30:21 +02:00
|
|
|
|
|
|
|
# rename the current .vim directory and .vimrc
|
|
|
|
mv "$HOME/.vim" "$HOME/.vim.bak"
|
|
|
|
mv "$HOME/.vimrc" "$HOME/.vimrc.bak"
|
|
|
|
|
|
|
|
# point the $HOME/.vim name to the USB for source routing
|
|
|
|
# use the USB drive's copy of .vimrc
|
|
|
|
ln -s /Volumes/Untitled\ 1/.vim "$HOME/.vim"
|
|
|
|
cp /Volumes/Untitled\ 1/.vimrc "$HOME/"
|
|
|
|
|
|
|
|
echo ".vim now points to /Volumes/Untitled\ 1/.vim"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Done."
|
|
|
|
|