Paste: Factor System-wide

Author: azteca
Mode: factor
Date: Thu, 15 Oct 2009 16:10:37
Plain Text |
Factor System-wide

I like the Factor listener and its powerful help system. You also get a debugger, a code walker, and much more with it. It's also a two-way tool if you use it with a supported editor. I personally use TextMate with the latest Factor TextMate bundle.

I however often use the terminal and like to have Factor handy system-wide. If I want to quickly test an idea, I like to start the terminal with Ctrl-Tab "T" (Quicksilver) and be able to just fire up Factor. Instead of entering the full path to factor or cd to it and run ./factor, I prefer calling it just like any other system command, by issuing a factor command in the terminal.

This can easily be done by creating a file (not a soft link because factor is not a self-contained executable) named factor pointing to the factor executable in your factor main folder. My Factor main folder is on my Desktop. Change the path to Factor's main folder accordingly in the following file. Don't forget to chmod 755 to make it executable.

cat ~/bin/factor
8<--------------------------------
#!/bin/sh
exec rlwrap "/Users/elie/Desktop/factor/factor" "$@"
8<--------------------------------

The location of the above file should be somewhere under you PATH. I have a personal bin folder under my home directory (~/bin) for that use. I also added rlwrap in the exec command for readline history and reverse-i-search (ctrl-r). I previously installed rlwrap with Macports.

Here's my .bashrc file. You can see that I added ~/bin to my $PATH.

cat ~/.bashrc
8<--------------------------------
export PATH="/opt/local/bin:/opt/local/sbin:~/bin:$PATH"
8<--------------------------------

You can also set 'Auto Use' on (available with the 'Auto Use" button in the listener) with the com-auto-use word.

Beyond running Factor scripts. You can also have in-place vocab scaffolding by adding your current "." folder to the vocab roots.

vocab-roots [ "." suffix ] change

The above line could be permanently added to your .factor-rc file but it currently disrupts the help system in the listener with a Permission denied (13) (probably due to searching on the "." path without the appropriate privileges).

New Annotation

Summary:
Author:
Mode:
Body: