tmux-resurrect/strategies/vim_session.sh
Bruno Sutic bd671b83dc
Don't be too smart when restoring vim session
A user may decide to use custom session file. Eg vim -S Session1.vim
With the previous approach we were preventing that as we only checked
for the existence of the default Session.vim file.
2020-06-05 09:24:42 +02:00

24 lines
429 B
Bash
Executable File

#!/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 (without the `-S` flag).
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