-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkworkspace.sh
executable file
·79 lines (62 loc) · 2.24 KB
/
mkworkspace.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
#===============================================================================
#
# FILE: mkworkspace.sh
#
# USAGE: ./mkworkspace.sh
#
# DESCRIPTION: Semi automated Eclipse Workspace and quick launcher creation
# In order to launch from Alfred needs to run from app compiled
# Apple script.
# Apple script runs Bash script in the background which provides
# the workspace specific arguments.
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Matt Coffey (),
# COMPANY:
# VERSION: 1.0
# CREATED: 11/10/14 15:43:27 GMT
# REVISION: ---
#===============================================================================
while getopts w: option
do
case "${option}"
in
w) WORKSPACE=${OPTARG};;
esac
done
# Exit if the argument is absent
if [[ -z $WORKSPACE || 'template' == $WORKSPACE || 's' == $WORKSPACE ]] ; then
echo "Invocation mkworkspace.sh -w [workspace]"
echo "[workspace] can't be 'template' or 's'"
exit 1;
fi
# Remove any existing files
~/bin/rmworkspace.sh -w "$WORKSPACE"
# Create script to open workspace
TEMPLATE_PATH="$HOME/workspaces/template"
BASE_PATH="$HOME/workspaces"
WORKSPACE_PATH="$BASE_PATH/$WORKSPACE"
BASH_PATH="$BASE_PATH/s/$WORKSPACE.sh"
APPLE_PATH="$BASE_PATH/s/$WORKSPACE.scpt"
echo "#!/bin/bash" > "$BASH_PATH"
echo "/opt/eclipse/Eclipse.app/Contents/MacOS/eclipse -showlocation -data $WORKSPACE_PATH -vmargs -Xms2048m -Xmx4096m -XX:MaxPermSize=2048M &" >> "$BASH_PATH"
chmod +x "$BASH_PATH"
# Create workspace
mkdir "$WORKSPACE_PATH"
cp -rp "$TEMPLATE_PATH/.metadata/" "$WORKSPACE_PATH/.metadata/"
# Create AppleScript file and provide instructions for Save As
echo "do shell script \"$BASH_PATH > /dev/null 2>&1 &\"" > "$APPLE_PATH"
# Provide instructions for Save As
echo "Select File -> (Hold ALT) Save As"
echo "File Format Application"
echo "uncheck Show startup screen"
echo "uncheck Stay open after run handler"
echo "Save As /Applications/$WORKSPACE.app"
echo "Click Save"
echo "To run from Alfred type $WORKSPACE"
# Open AppleScript Editor
open /Applications/Utilities/Script\ Editor.app "$APPLE_PATH"