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
#!/bin/sh
exec rlwrap "/Users/elie/Desktop/factor/factor" "$@"
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
export PATH="/opt/local/bin:/opt/local/sbin:~/bin:$PATH"
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 with:
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).
Now supposing you change directory to your Desktop (cd Desktop/) and want to start experimenting with a new vocab there before moving it later to the work or extra directory. You only need to enter the following to get started:
"." "my-vocab" scaffold-vocab
Sample session:
Elie:~ elie$ cd Desktop/
Elie:Desktop elie$ factor
Loading /Users/elie/.factor-rc
( scratchpad ) com-auto-use
1: com-auto-use
^
No word named ``com-auto-use'' found in current vocabulary search path
The following restarts are available:
:1 Use the ui.tools.listener vocabulary
:2 Defer word in current vocabulary
Type :help for debugging help.
( scratchpad ) :1
1: Note:
Added "ui.tools.listener" vocabulary to search path
( scratchpad - auto ) vocab-roots [ "." suffix ] change
( scratchpad - auto ) "." "my-vocab" scaffold-vocab
1: Note:
Added "tools.scaffold" vocabulary to search path
Creating scaffolding for P" my-vocab/my-vocab.factor"
Creating scaffolding for P" my-vocab/authors.txt"
Loading my-vocab/my-vocab.factor
( scratchpad - auto )



No comments:
Post a Comment