-
Notifications
You must be signed in to change notification settings - Fork 0
/
setCommandWindowTitle.m
67 lines (55 loc) · 1.87 KB
/
setCommandWindowTitle.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
function setCommandWindowTitle(str)
% setCommandWindowTitle customize command window title with hostname and optional string
%
% setCommandWindowTitle
% title: ( hostname ) MATLAB R2099z
%
% setCommandWindowTitle(str)
% title: ( hostname ) -- str -- MATLAB R2099z
%
%
% JRI 6/29/13 [email protected]
if isunix && ~isTextOnlyMatlabSession,
[~,hn]=unix('hostname;');
hn = deblank(hn);
ver = regexp(version,'\(([^)]+)\)','tokens');
originalCommandWindowTitle = sprintf('MATLAB %s',ver{1}{1});
if ~nargin,
newTitle = sprintf('( %s ) %s', hn, originalCommandWindowTitle);
else
newTitle = sprintf('( %s ) -- %s -- %s', hn, str, originalCommandWindowTitle);
end
% jri private
if isParallel,
global JRI_N_THREADS JRI_THIS_THREAD JRI_START_OFFSET
if ~isempty(JRI_START_OFFSET) && JRI_START_OFFSET~=0,
offStr = sprintf(' (+%d)',JRI_START_OFFSET);
else
offStr = '';
end
parStr = sprintf(' << Par %d of %d%s >>', JRI_THIS_THREAD, JRI_N_THREADS, offStr);
newTitle = [newTitle parStr];
end
%setPrompt([hn(1:3) ' >> ']); %put hostname into command prompt
%better approach: add hostname to command window title (http://stackoverflow.com/questions/1924286)
jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jDesktop.getMainFrame.setTitle(newTitle);
end
function bool = isTextOnlyMatlabSession
% isTextOnlyMatlabSession test if this matlab instance can plot or is text only
%
% JRI 7/26/13
bool = usejava('jvm') && ~usejava('Desktop');
function bool = isParallel
% isParallel Are we processing in parallel?
%
% bool = isParallel
%
% return true if we're processing in parallel
% use to disable plotting, for example
%
% uses globals JRI_N_THREADS JRI_THIS_THREAD
%
% JRI 7/11/07
global JRI_N_THREADS
bool = ~isempty(JRI_N_THREADS);