setPrompt - Set the Command Window prompt
by Yair Altman
24 Jan 2010
(Updated 29 Jan 2010)
Sets the Command Window prompt to the specified string
|
Watch this File
|
| File Information |
| Description |
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) |
| Acknowledgements |
The author wishes to acknowledge the following in the creation of this submission:
cprintf - display formatted colored text in the Command Window
|
| MATLAB release |
MATLAB 7.6 (R2008a)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 26 Jan 2010 |
Fixed a few edge cases (some inspired by J. Raymond); added continuously-updated timestamp option |
| 29 Jan 2010 |
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 |
|
Contact us at files@mathworks.com