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 Center および MATLAB AnswersStartup and Shutdown についてさらに検索
謝辞

ヒントを得たファイル: cprintf - display formatted colored text in Command Window

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