update readme

This commit is contained in:
Sami Samhuri 2011-05-18 00:14:54 -07:00
parent 934b3980b6
commit 89cce91212

View file

@ -5,75 +5,56 @@ Use your text editor to edit commands in Node's repl.
(tip o' the hat to Giles Bowkett for [inspiration](http://gilesbowkett.blogspot.com/2010/09/vim-in-irb-with-utility-belt.html)) (tip o' the hat to Giles Bowkett for [inspiration](http://gilesbowkett.blogspot.com/2010/09/vim-in-irb-with-utility-belt.html))
Installation Installation
============ ============
npm install repl-edit npm install repl-edit
Usage Usage
===== =====
You can fire up a repl with editing capabilities by running `node-repl-edit`. Typically you just type `require('repl-edit')` in node's repl and it will extend it with new commands, just like `.break` and `.clear` that come with node.
(It would be nice to extend an existing repl session but that's not possible with
Node's repl module right now.)
You can also fire up a repl with editing capabilities by running `node-repl-edit` in your shell.
Commands Commands
======== ========
edit .edit
----
The first time you run `edit()` in a repl a temporary file is created, specific to that session,
and opened in your editor. Type away and then save and close the file when you're done. The file
is loaded and executed immediately.
run
---
To run whatever command you've been working on without editing it again type `run()`.
setEditor
---------
`setEditor('mate -w')` changes your editor to TextMate for this session. Note that this
command sets the environment variable EDITOR for the repl process.
stash
----- -----
`stash('/path/to/a/file')` saves your command to the named file. `.edit` opens your editor. Type away and then save and close the file when you're done. The command will be loaded and executed immediately.
Your editor is determined by the `VISUAL` and `EDITOR` environment variables, in that order. You can also change the editor for a single edit by doing something like `.edit vim`.
unstash .run
----
`.run` runs the most recent command you've edited.
.editor
------- -------
`unstash('/path/to/a/file')` restores the contents of that file for you to run and/or edit. `.editor mate -w` changes your editor to TextMate for this session, by setting the environment variable `VISUAL`.
.stash
------
Future `.stash /path/to/a/file` saves your command to the named file.
======
Instead of polluting the global namespace with functions I'd rather extend Node's repl .unstash
to allow user-defined dot commands (just like `.break` and `.clear`), and then use that --------
capability to provide commands like `.edit` and `.stash <filename>`.
The first time edit() is run in a repl instead of an empty file the command should be seeded `.unstash /path/to/a/file` restores the contents of that file for you to run and/or edit.
with the last command that was executed.
If the native repl module exports the currently running repl object it will be possible to attach TODO
to an existing repl instead of having to run a separate binary that loads a repl. ====
The first time `.edit` is run instead of an empty file the command should be seeded with the last command that was executed.
License License
======= =======
Copyright 2010 Sami Samhuri sami@samhuri.net Copyright 2010 - 2011 Sami Samhuri <sami@samhuri.net>
MIT (see the file named [LICENSE](/samsonjs/repl-edit/blob/master/LICENSE)) MIT license, see the included [LICENSE](/samsonjs/repl-edit/blob/master/LICENSE)