Harucom’s IRB runs commands for looking at files and copying them.

irb> ls
irb> cat hello.rb

These commands are Ruby scripts stored in /app. You can print one with cat, or change it with the edit command. See File I/O for details.

Contents

Looking at Files

ls — List files

irb> ls
irb> ls /app
irb> ls -l

Lists the files in the current directory. Directories are shown in a different color from files.

cat — Show the contents of a file

irb> cat hello.rb
irb> cat -n hello.rb
irb> cat file1.rb file2.rb

Prints the file as it is. -n numbers each line. Several files given at once are printed one after another.

head / tail — Show the beginning or the end

irb> head hello.rb
irb> head -n 20 hello.rb
irb> tail hello.rb

head prints the beginning of a file and tail prints the end. -n changes how many lines they show.

Moving Around

pwd — Print the current directory

irb> pwd
/

cd — Change directory

irb> cd /app
irb> cd ..
irb> cd

Changes the directory you are working in, the current directory. After moving, a plain file name passed to ls, cat, or edit refers to a file in that directory.

irb> cd /app
irb> cat ls.rb

Running cd without an argument moves to the root directory /.

Working with Files

touch — Create an empty file

irb> touch memo.txt

cp — Copy a file

irb> cp hello.rb backup.rb
irb> cp hello.rb /data/
irb> cp -f hello.rb backup.rb

When the destination is a directory, the file is copied into it under the same name. An existing file is not overwritten unless you pass -f.

mv — Move or rename a file

irb> mv old.rb new.rb
irb> mv hello.rb /data/
irb> mv -f hello.rb existing.rb

This works like cp. A destination directory receives the file under the same name.

rm — Delete files

irb> rm memo.txt
irb> rm file1.txt file2.txt

Several files can be given at once.

Harucom needs /system.rb and the files under /lib, /app, and /etc in order to boot, so these are protected. -f overrides the protection, but the board may stop booting.

Working with Directories

mkdir — Create a directory

irb> mkdir data
irb> mkdir /data/photos

rmdir — Remove an empty directory

irb> rmdir data

A directory that still holds files cannot be removed. Delete the files with rm first. As with rm, system directories need -f.

Other Commands

Command Description
edit Edit a file in the text editor
run Run a Ruby script
zoom Change the text size on screen New in 2.0
picorabbit Show slides
johakyu Live code sound and light New in 2.0

IRB itself provides a few commands.

Command Description
jobs Show whether an app is suspended New in 2.0
fg Resume the suspended app New in 2.0
exit Quit IRB and start it again

An app that supports it, such as picorabbit, stops and hands you back to IRB when you press Ctrl-Z while it runs. Typing fg picks it up where it left off. New in 2.0

To try out the built-in demos, see Demo Apps.