Recording and sharing shell commands with Shelr

Slashdot it! Delicious Share on Facebook Tweet! Digg!
Lead Image © Ann Triling, 123RF.com

Lead Image © Ann Triling, 123RF.com

Command Line Cinema

The Ruby tool Shelr transforms the command line into a motion picture, and you can even copy the commands to the clipboard.

Do blockbusters elicit a yawn? Does the command line excite you with further possibilities? Do you want to direct your own film starring Linux commands instead of kids, cats, and dogs? Then, Shelr is what you need.

The Shelr [1] program is implemented in Ruby and is licensed under GPLv3. Shelr allows you to capture command-line activity in the form of a video and either archive it as a memory aid or share it with others in a tutorial or talk. You can use the Shelr.tv [2] online service to host your screen videos in the best YouTube manner (Figure 1). Shelr.tv is better than YouTube because it lets you extract content from the stream and copy-and-paste it into the console.

Figure 1: Shelr.tv lets you extract content from videos.

You can set up Shelr in no time, and many distributions already feature it in their repositories. If Shelr is missing from your distro's repository, as is the case with Debian "Squeeze," simply install Ruby and RubyGems and then get Shelr, along with its dependencies, from the Ruby repository by issuing the following command:

$ sudo gem install shelr

Shelr requires few commands, making it easy to learn. In the background, Shelr uses the script utility from the util-linux or util-linux-ng packages to record the terminal session, acting as a front end that manages your masterpieces and sets up the connection with Shelr.tv. Then, Shelr and script fork to shell and send their output to a TypeScript file that you can play back or print out later.

Keeping Track of Output

Shelr resides in the default directory /var/lib/gems/version_no/bin , which is not normally in the path. The following command can help with that:

$ export PATH=/var/lib/gems/version_no/bin:$PATH

Entering the same export line in the ~/.bashrc file works, and you don't have to expand the variable in the future.

To use Shelr to record terminal input, all you need is the shelr record command. The program prompts you for a title for your recording and then lets loose (Figure 2). The software logs all input and saves the data in a TypeScript file in the ~/.local/share/shelr/<ID>/typescript directory. When all is said and done, end the process with exit or Ctrl+D. The shelr play last command is for playback.

Figure 2: The shelr record command is all you need to begin recording.

If you're happy enough with the result to share your work with others, you can enter the shelr push last command to push it to Shelr.tv. The program asks you to add a meaningful description. If no errors occur when uploading, the software displays the URL of the published TypeScript file.

Naturally, you don't have to publish your creations on Shelr.tv. You can keep your collection for yourself and share it with friends and family. If you use Shelr regularly, you will begin to amass a large collection of videos.

If the TypeScript filename format, which is based on Unix timestamps, makes it difficult to find a video from the past, the shelr list command can help; it lists the title of the video. Copy the ID of the desired title into the shelr play ID command, or use the shelr push ID command to push the video to Shelr.tv (Figure 3).

Figure 3: IDs are nothing more than Unix timestamps that Shelr uses to identify shell casts.

Shelr.tv

Even hardworking filmmakers sooner or later become curious about the work of others. You can view videos from other filmmakers at the Shelr.tv web page. If the browser is bothersome or a graphical environment is missing, use the following command to extract the video and start the playback:

$ shelr play http://shelr.tv/records/ID_no.json

The push command makes it possible to publish works as an anonymous user. To get some renown for your shell casting, you need an API key, which you get rather easily through an account with GitHub, Twitter, Google, or OpenID. It's as easy as registering with one of these services on Shelr.tv (Figure 4). Follow up by getting an API key with shelr setup Key , and your videos will then be associated with your nickname.

Figure 4: Registering an API key provides you with a nickname.

If you don't want to use Shelr.tv, you can also use the API to associate the script with a URL. If you're hesitant to share your work with the common masses, add the --private option when using push . In this case, the viewer also needs an access key, along with the public ID, to enjoy the video (Figure 5). The Shelr.tv server renders the uploaded recordings into JSON objects. (To do this locally, use the dump command.)

Figure 5: Use the --private option for a more restricted access to your masterworks.

Buy this article as PDF

Express-Checkout as PDF

Pages: 3

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content