- Reduce typing of long lines.
- Implement new functionality (e.g. move/rename).
- Provide common Linux shortcuts at the rshell > prompt.
- Use common shortcuts to achieve project-specific effects.
At the > prompt macros are expanded with a new m command. This session shows the use of two macros mv (move/rename a file) and lf (list the flash drive). After each invocation of a macro its expansion is displayed followed by the outcome of running it.
Code: Select all
/home/adminpete> m mv /flash/test.py /flash/test01.py
cp /flash/test.py /flash/test01.py; rm /flash/test.py
/home/adminpete> m lf
ls -al /flash/
366 Aug 15 09:14 boot.py
579 Aug 15 09:44 do_connect.py
34 Dec 31 2014 main.py
0 Sep 1 07:41 micropython_ra8875/
2817 Dec 31 2014 pybcdc.inf
0 Sep 3 07:32 test01.py
/home/adminpete>
Code: Select all
macros = {}
macros['..'] = 'cd ..'
macros['...'] = 'cd ../..'
macros['ll'] = 'ls -al {}', 'List arbitrary directory'
macros['lf'] = 'ls -al /flash/{}'
macros['lsd'] = 'ls -al /sd/{}'
macros['lpb'] = 'ls -al /pyboard/{}'
macros['mv'] = 'cp {0} {1}; rm {0}', 'Move/rename'
# A project specific example
macros['cpd'] = 'cp foo/demos/{0}.py /flash/foo/demos/; repl ~ import foo.demos.{0}', 'Copy a demo file and run it'
Code: Select all
/home/adminpete> m proj fonts
ls -l /flash/micropython_ra8875/fonts
0 Sep 1 07:42 __init__.py
13912 Sep 1 07:42 font10.py
19785 Sep 1 07:42 font14.py
/home/adminpete>