我从不使用 GUI,并且总是在使用 -nodesktop -nodisplay 选项设置的终端(也是全屏,因此没有标题栏)内。我还连接了不同的服务器来运行 matlab,每个服务器对占用计算资源都有不同的限制。由于很难记住我所在的服务器,特别是如果我打开了多个会话,我想知道是否可以更改提示以显示服务器名称。尽我所能,我找不到解释如何进行操作的资源(我开始认为 Mathworks 不支持它)。我知道,解决方法是简单地编写一个对 system('hostname')
的函数调用并将该函数放在路径中,这样就像输入 pwd
一样简单> 查找目录。我想知道是否有更优雅的东西。
I never work with the GUI and am always inside a terminal (also full screen, so no title bar) set with the -nodesktop -nodisplay option. I also have different servers that I connect to, to run matlab and each of those have different restrictions on hogging computational resources. Since it's hard to remember which server I'm in,especially if I have multiple sessions open, I was wondering if I could change the prompt to display the server name. Try as I might, I couldn't find a resource that explains how to go about it (I'm beginning to think Mathworks doesn't support it). I know, a workaround would be to simply write a function call to system('hostname')
and put the function in the path, so that it's about as easy as typing pwd
to find the directory. I'd like to know if there's something more elegant.
发布评论
评论(1)
MathWorks File Exchange 上有一个提交可以为您执行此操作:setPrompt 通过 Yair Altman。在 R2010b 中使用它时,我注意到收到了警告消息:
我可以使用
警告
功能如下:以下是我如何使用
system
函数:函数
deblank
用于从字符串中删除尾随空格(在本例中为换行符)。注意:退出并重新启动 MATLAB 后,上述更改(抑制警告和修改提示)不会持续存在,因此您可以将上述代码放入 startup.m 文件 以在每次启动新会话时自动应用它们。
There is a submission on the MathWorks File Exchange that can do this for you: setPrompt by Yair Altman. Using it in R2010b, I noticed that I was getting the warning message:
Which I was able to suppress using the
warning
function like so:And here's how I changed the prompt to the host name using the
system
function:The function
deblank
is used to remove trailing whitespace (in this case a newline) from the string.NOTE: The above changes (suppressed warning and modified prompt) don't persist after you quit and restart MATLAB, so you could put the above code in your startup.m file to apply them automatically every time you start a new session.