Hack 38. Text Editing with vi on Your TiVo

   

Hack 38 Text Editing with vi on Your TiVo

figs/moderate.gif figs/hack38.gif

Nothing says text editing like vi, the default Unix editor .

When you think of text editing, you probably think Microsoft Word, Word Perfect, AppleWorks, BBEdit, Notepad, or the like. I'm afraid you won't find any of these on your TiVo. In fact, about all you have at your disposal is the echo command we used to tack commands onto the end of TiVo's rc.sysinit . While you can use echo to add new lines to the beginning or the end of a file, this command gets frustrating quickly when you want to add lines in the middle of a file, and it becomes nearly impossible if you want to alter a particular line.

For Unix geeks , nothing says text editing like vi or Emacs [Hack #39], but we'll get that running in just a moment. A mainstay of just about any Unix system, the vi editor is small, lightweight, and packed with geek-worthy power and functionality.

Installing elvis

Drew Streib has ported a version of elvis , a simple vi clone, to the Series 1 TiVo architecture. Grab a copy at ftp://ftp.alt.org/pub/tivo/dtype/elvis-1.4_Tivo-1.tar.gz and expand it on your PC. In the archive you'll find an elvis binary file. Copy the elvis binary over to your TiVo [Hack #36] and drop it into the /var/hack/bin directory.

Make the program executable using the chmod command, like so:

 bash-2.02#  chmod 755 /var/hack/bin/elvis  

Running elvis

On a TiVo, chances are that elvis won't "just work" at this point, but give it a shot:

 bash-2.02#  elvis  Unrecognized TERM type 

If you get an "Unrecognized TERM type" error, your TiVo is not yet set up to properly interact with your terminal program beyond basic input/output. This is usually the case and can be fixed pretty easily. Inside the elvis-1.4_Tivo-1.tar.gz archive, there is a terminfo.tar file. Move the terminfo.tar file from the archive you downloaded over to your TiVo and plop it in /var/hack . Next, make a terminfo directory and use cpio to unpack it and put it into place:

 bash-2.02#  mkdir /var/hack/terminfo  bash-2.02#  cd /var/hack  bash-2.02#  cpio -i -H tar --make-directories < terminfo.tar  

This will supply TiVo with all the information necessary for it to display full-screen terminal programs. We just need to tell TiVo where to find the terminal information files. The easy way is to just set the TERMINFO environment variable to the /var/hack/terminfo directory:

 bash-2.02#  export TERMINFO=/var/hack/terminfo  

With the TERMINFO set, we should be able to use elvis by invoking it on the command line. In fact, you can give it a whirl by editing your /.profile file to include the TERMINFO information:

 bash-2.02#  mount -o remount,rw /  bash-2.02#  elvis /.profile  bash-2.02#  mount -o remount,ro /  

See Also

  • Learning the vi Editor (http://www.oreilly.com/catalog/vi6/)


   
Top


Tivo Hacks. 100 Industrial-strength Tips Tools 2003
Tivo Hacks. 100 Industrial-strength Tips Tools 2003
ISBN: 1597490318
EAN: N/A
Year: 2004
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net