setPrompt - Set the Command Window prompt

Sets the Command Window prompt to the specified string

現在この提出コンテンツをフォロー中です。

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 (2026). setPrompt - Set the Command Window prompt (https://jp.mathworks.com/matlabcentral/fileexchange/26471-setprompt-set-the-command-window-prompt), MATLAB Central File Exchange. に取得済み.

謝辞

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

カテゴリ

Help Center および MATLAB AnswersStartup and Shutdown についてさらに検索

一般的な情報

MATLAB リリースの互換性

  • すべてのリリースと互換性あり

プラットフォームの互換性

  • Windows
  • macOS
  • Linux
バージョン 公開済み リリース ノート Action
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