-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
vimtutor-sequel.sh
executable file
·35 lines (27 loc) · 1.03 KB
/
vimtutor-sequel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
VERSION="1.3.1" # TODO: Update this with each new release
# Define the location of the vimtutor-sequel.txt file and vimrc
# Where brew installs the files using `pkgshare` command
BREW_PREFIX=$(brew --prefix)
TUTORIAL_FILE="$BREW_PREFIX/share/vimtutor-sequel/vimtutor-sequel.txt"
VIMRC_FILE="$BREW_PREFIX/share/vimtutor-sequel/vimtutor-sequel.vimrc"
TEMP_FILE="/tmp/vimtutor-sequel.txt"
# Check if the tutorial file exists
if [ ! -f "$TUTORIAL_FILE" ]; then
echo "Vimtutor Sequel file not found!"
exit 1
fi
# Handle version flag
if [[ "$1" == "--version" || "$1" == "-v" ]]; then
echo "Vimtutor Sequel version $VERSION"
exit 0
fi
# Ensure the temporary file is deleted if it already exists
rm -f "$TEMP_FILE"
# Copy the tutorial file to a temporary location
cp "$TUTORIAL_FILE" "$TEMP_FILE"
# Open the temporary tutorial file in Vim with the custom vimrc
# Add -U NONE to not interfere with user-specific Vim settings
vim -u "$VIMRC_FILE" -U NONE "$TEMP_FILE"
# Clean up the temporary file after Vim exits
rm -f "$TEMP_FILE"