Command strategies; restore vim sessions

Closes #4
This commit is contained in:
Bruno Sutic
2014-08-28 00:43:31 +02:00
parent 07bba0fde7
commit cde50d4d92
4 changed files with 74 additions and 5 deletions

23
strategies/vim_session.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# "vim session strategy"
#
# Restores a vim session from 'Session.vim' file, if it exists.
# If 'Session.vim' does not exist, it falls back to invoking the original
# command.
ORIGINAL_COMMAND="$1"
DIRECTORY="$2"
vim_session_file_exists() {
[ -e "${DIRECTORY}/Session.vim" ]
}
main() {
if vim_session_file_exists; then
echo "vim -S"
else
echo "$ORIGINAL_COMMAND"
fi
}
main