tvl-depot/usbify/vim/vim_point_to_usb.sh

39 lines
1,015 B
Bash
Raw Normal View History

2016-08-01 21:30:21 +02:00
#!/usr/bin/env bash
path_to_ext_device="/Volumes/usb_vim"
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 "${path_to_ext_device}/.vim" "$HOME/.vim"
ln -s "${path_to_ext_device}/.vimrc" "$HOME/.vimrc"
2016-08-01 21:30:21 +02:00
echo ".vim now points to ${path_to_ext_device}/.vim"
2016-08-01 21:30:21 +02:00
fi
echo "Done."