Create a select menu with smenu

Not Spoiled for Choice

© Lead Image © acik, 123RF.com

© Lead Image © acik, 123RF.com

Article from Issue 205/2017
Author(s):

The smenu tool reduces the effort of creating shell menus to one line, with numerous options for a wide range of design alternatives.

If you program for the shell frequently, sooner or later you will have to create a select menu, which usually requires several lines of code – unless you use smenu. Smenu reduces the menu's script to a single line. A number of parameters allow you to adapt the design and to simplify your work a little.

The source code for smenu is available on its project page [1], which contains installation instructions, as well as some useful tips. The smenu wiki [2] contains links to two YouTube videos that demonstrate the practical use of the program. The README file provides a structured overview of smenu's options [1].

Basic Function

In smenu's simplest form, a command's output is passed via pipe to the smenu command. For example, <command> | smenu displays a selection on a single line. To create a line-by-line menu, use <command> | smenu -c (Figure 1).

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

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

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Scripted Printing

    A few commands and some simple shell scripts make it easier to manage your printer so that you can access print functions quickly and automate recurring tasks.

  • Time Machines

    Command-line aficionados do not have to forgo calendars and appointment reminders. The shell offers many tools for user-friendly handling of date definitions in scripts.

  • Metadata in the Shell

    Armed with the right shell commands, you can quickly identify and evaluate file and directory metadata.

  • Printing in the Shell

    Use shell commands to start and manage print jobs without too much clicking, while easily avoiding problems with specific file formats.

  • FOSSPicks

    Graham explores GnuCash 3, Kawaii-Player 3.3.1, tig, HandBrake 1.1.0, GameMode, XLEngine, and more!

comments powered by Disqus