-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsampleStartup.m
113 lines (92 loc) · 3.61 KB
/
sampleStartup.m
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
%% Startup script for use with the Toolbox Toolbox.
%
% Here is a sample startup.m for works with the ToolboxToolbox. You
% should copy this file to your system outside of the ToolboxToolbox
% folder. You should rename this file to "startup.m". You should edit
% Your startup.m with the correct toolboxToolboxDir, and any Matlab
% preferences you wish to change for your local machine.
%
% This sample is focused on the ToolboxToolbox. You can include additional
% startup actions, if you wish.
%
% 2016-2017 [email protected]
%% Where is ToolboxToolbox installed?
% a reasonable default, or pick your own
pathString = userpath();
if isempty(pathString)
% userpath() was not set, try to choose a "home" folder
if ispc()
userFolder = fullfile(getenv('HOMEDRIVE'), getenv('HOMEPATH'));
else
userFolder = getenv('HOME');
end
else
% take the first folder on the userpath
firstSeparator = find(pathString == pathsep(), 1, 'first');
if isempty(firstSeparator)
userFolder = pathString;
else
userFolder = pathString(1:firstSeparator-1);
end
end
toolboxToolboxDir = fullfile(userFolder, 'ToolboxToolbox');
%% Set up the path.
originalDir = pwd();
try
apiDir = fullfile(toolboxToolboxDir, 'api');
cd(apiDir);
tbResetMatlabPath('reset', 'full');
catch err
warning('Error setting ToolboxToolbox path during startup: %s', err.message);
end
cd(originalDir);
%% Put /usr/local/bin on path so we can see things installed by Homebrew.
if ismac()
setenv('PATH', ['/usr/local/bin:' getenv('PATH')]);
end
%% Matlab preferences that control ToolboxToolbox.
% clear old preferences, so we get a predictable starting place.
if (ispref('ToolboxToolbox'))
rmpref('ToolboxToolbox');
end
% choose custom preferences below, or leave commented to accept defaults
% % default location for JSON configuration
% configPath = fullfile(tbUserFolder(), 'toolbox_config.json');
% setpref('ToolboxToolbox', 'configPath', configPath);
% % default folder to contain regular the toolboxes
% toolboxRoot = fullfile(tbUserFolder(), 'toolboxes');
% setpref('ToolboxToolbox', 'toolboxRoot', toolboxRoot);
% % default folder to contain shared, pre-installed toolboxes
% toolboxCommonRoot = '/srv/toolboxes';
% setpref('ToolboxToolbox', 'toolboxCommonRoot', toolboxCommonRoot);
% % default folder to contain non-toolbox projects
% projectRoot = fullfile(tbUserFolder(), 'projects');
% setpref('ToolboxToolbox', 'projectRoot', projectRoot);
% % default folder for hooks that set up local config for each toolbox
% localHookFolder = fullfile(tbUserFolder(), 'localHookFolder');
% setpref('ToolboxToolbox', 'localHookFolder', localHookFolder);
% % location of ToolboxHub or other toolbox registry
% registry = tbDefaultRegistry();
% setpref('ToolboxToolbox', 'registry', registry);
% system command used to check whether the Internet is reachable
% this helps avoid long timeouts, when Internet isn't reachable
% many commands would work fine
% some suggestions:
%
% good default for Linux and OS X
% checkInternetCommand = 'ping -c 1 www.google.com';
%
% good default for Windows
% checkInternetCommand = 'ping -n 1 www.google.com';
%
% alternatives in case ping is blocked by firewall, etc.
% checkInternetCommand = 'curl www.google.com';
% checkInternetCommand = 'wget www.google.com';
%
% no-op to assume Internet is always reachable
% checkInternetCommand = '';
%
% setpref('ToolboxToolbox', 'checkInternetCommand', checkInternetCommand);
% uncomment and set noIgnoreEnv true to make TbTb not use 'env -i' to launch git commands
% noIngoreEnv = false;
% setpref('ToolboxToolbox', 'noIgnoreEnv', noIngoreEnv);