forked from shohei/vim-fidget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfidget.sh
More file actions
executable file
·30 lines (26 loc) · 893 Bytes
/
fidget.sh
File metadata and controls
executable file
·30 lines (26 loc) · 893 Bytes
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
#!/bin/bash
if [ "$FIDGETDIR" == "" ]; then
FIDGETDIR=/tmp
fi
if [ "$1" == "" ]; then
FIDGET=$FIDGETDIR/`python -c "import random; print hex(int(str(random.random())[2:10]))[2:]"`
else
FIDGET=$FIDGETDIR/$1
fi
echo "Creating fiddle to $FIDGET"
# set -e makes sure that we exit on failure
(set -e;
# get the actual file path avoiding symlinks
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo $DIR
mkdir $FIDGET;
cp $DIR/template/* $FIDGET;
echo $FIDGET
node $DIR/node_server.js $FIDGET >/dev/null 2>/dev/null &
)