-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·45 lines (39 loc) · 1.01 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·45 lines (39 loc) · 1.01 KB
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
36
37
38
39
40
41
42
43
44
#!/bin/bash
SOURCE_DIR=./snippets
BUILD_DIR=./build
mkdir $BUILD_DIR || { echo 'delete build directory and try again'; exit 1; }
for install in $(find $SOURCE_DIR -name 'install.txt')
do
fullcodedir=$(dirname $install)
codedir=${fullcodedir#$SOURCE_DIR/}
cat $install | while read code
do
if [[ ! -z $code ]]
then
mkdir -p $BUILD_DIR/$codedir
snippet=$BUILD_DIR/$codedir/$code.sublime-snippet
cat <<EOT >> $snippet
<snippet>
<content><![CDATA[
EOT
cat $fullcodedir/$code.cpp >> $snippet
cat <<EOT >> $snippet
]]></content>
<tabTrigger>$code</tabTrigger>
<scope>source.c++</scope>
</snippet>
EOT
echo "collected $codedir/$code"
fi
done
done
echo "snippets collected to $BUILD_DIR"
SUBLIME_PATH="$HOME/Library/Application Support/Sublime Text/Packages/User"
SNIPPET_DIR=algorithms-cpp
if [ -d "$SUBLIME_PATH" ]
then
rm -rf "$SUBLIME_PATH/$SNIPPET_DIR"
mkdir "$SUBLIME_PATH/$SNIPPET_DIR"
cp -r $BUILD_DIR/* "$SUBLIME_PATH/$SNIPPET_DIR/"
echo "snippets installed to $SUBLIME_PATH/$SNIPPET_DIR"
fi