setPrompt - Set the Command Window prompt

版本 1.4.0.0 (11.9 KB) 作者: Yair Altman
Sets the Command Window prompt to the specified string
2.2K 次下载
更新时间 2014/10/20

查看许可证

setPrompt(newPrompt) sets the Command Window prompt to the specified NEWPROMPT.
NEWPROMPT can be one of the following:

- a static string: setPrompt('>> ')
=> this is the default prompt string ('>> ')

- an evaluable string: setPrompt('datestr(now)')
=> the new prompt will look like: '25-Jan-2010 01:00:51'
Note: the evaluable string is expected to return a string

- an evaluable function: setPrompt(@()(['[',datestr(now),'] ']))
=> the new prompt will look like: '[25-Jan-2010 01:00:51] '
Note: the evaluable function is expected to return a string

- the static string 'timestamp' will continuously update the last (current)
prompt with the current time: '[25-Jan-2010 01:00:51] '. This has
the effect of displaying desktop command execution times.
The 'timestamp' string can be used with other static text to
customize its appearance. For example: setPrompt('<timestamp!> ').
- an empty value or no input argument restores the default prompt

Examples:
setPrompt('[-]') % Replaces '>> ' prompt with '[-]'
setPrompt('%') % => '% ' (space-padded)
setPrompt('sprintf(''<%f>'',now)') % => '<734163.056262>'
setPrompt('datestr(now)') % => '25-Jan-2010 01:00:51' (unchanging)
setPrompt('[''['',datestr(now),''] '']') % => '[25-Jan-2010 01:00:51] '
setPrompt(@()(['[',datestr(now),'] '])) % => '[25-Jan-2010 01:00:51] '
(note that these are the same: the first uses an evaluable string,
while the second uses an evaluable function)
setPrompt('timestamp') % => '[25-Jan-2010 01:00:51] ' (continuously-updated)
setPrompt('<timestamp> ') % => '<25-Jan-2010 01:00:51> ' (continuously-updated)
setPrompt('>> ') % restores the default prompt
setPrompt('') % restores the default prompt
setPrompt % restores the default prompt

Warning:
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+, but use at your own risk!

Technical explanation:
A technical explanation of the code in this utility can be found on http://undocumentedmatlab.com/blog/setprompt-setting-matlab-desktop-prompt/

Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)

引用格式

Yair Altman (2024). setPrompt - Set the Command Window prompt (https://www.mathworks.com/matlabcentral/fileexchange/26471-setprompt-set-the-command-window-prompt), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2008a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.4.0.0

Updated submission title (no code change)

1.3.0.0

Fixed for R2014a & R2014b

1.2.0.0

Fixed a few edge-cases (some reported by J.G. Dalissier) with '>> ' terminated prompts; fixed a few problems with continuous timestamps; enabled customizing continuous timestamp prompts; added Mac warning

1.1.0.0

Fixed a few edge cases (some inspired by J. Raymond); added continuously-updated timestamp option

1.0.0.0