summaryrefslogtreecommitdiffstats
path: root/README.rst
blob: bdc841e4833aa2f2578c9273a37d3e82b02a21f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
What is it?
===========
**smenu** is a selection filter just like ``sed`` is an editing filter.

This simple tool reads words from the standard input, presents them in
a cool interactive window after the current line on the terminal and writes
the selected word, if any, on the standard output.

After having unsuccessfully searched the NET for what I wanted, I
decided to try to write my own.

I have tried hard to made its usage as simple as possible. It should
work, even when using an old ``vt100`` terminal and is ``UTF-8`` aware.

How to build?
=============
**smenu** can be built on every system where a working ``terminfo``
developpement platform is available. This includes every Unix and Unix
like systems I am aware of.

You may need to adjust the ``CURSES`` variable in the Makefile. On Linux,
by example, you need ``ncurses``.

After that, a simple ``make`` should be sufficient to build the program.

There is no installation procedure as all that is required to do is to
put the resulting binary and the man page in their traditional places.

Some examples.
==============

Linux example.
--------------
This program should work on most Unix but if you are using Linux,
try to type the following line at a shell prompt (here: ``"$ "`` ):

::

  $ R=$(grep Vm /proc/$$/status \
        | IFS=$':\n' smenu -n20 -q -c -b -g -s /VmH)
  $ echo $R

Something like this should now be displayed with the program waiting
for commands: (numbers are mine, yours will be different)

::

  VmPeak¦    23840 kB¦
  VmSize¦    23836 kB¦
  VmLck ¦        0 kB¦
  VmHWM ¦     2936 kB¦
  VmRSS ¦     2936 kB¦
  VmData¦     1316 kB¦
  VmStk ¦      136 kB¦
  VmExe ¦       28 kB¦
  VmLib ¦     3956 kB¦
  VmPTE ¦       64 kB¦
  VmSwap¦        0 kB¦

A cursor should be under ``"VmHWM "``.

After having moved the cursor to ``"      136 kB"`` and ended the program
with ``<Enter>``, the shell variable R should contain: ``"      136 kB"``.

.. raw:: pdf

  PageBreak

Unix example.
-------------
The following command, which is Unix brand agnostic, should give you a
scrolling window if you have more than 10 accounts on your Unix with a
UID lower than 100:

::

  $ R=$(awk -F: '$3 < 100 {print $1,$3,$4,$NF}' /etc/passwd \
        | smenu -n10 -c)
  $ echo $R

On mine (``LANG`` and ``LC_ALL`` set to ``POSIX``) it displays:

::

  at      25 25  /bin/bash      \
  sys     0  3   /usr/bin/ksh   +
  bin     1  1   /bin/bash      |
  daemon  2  2   /bin/bash      |
  ftp     40 49  /bin/bash      |
  games   12 100 /bin/bash      |
  lp      4  7   /bin/bash      |
  mail    8  12  /bin/false     |
  named   44 44  /bin/false     |
  ntp     74 108 /bin/false     v

Note the presence of a scrollbar.

Interested?
-----------
Please read the included man page to learn more about this little program.

On Linux, ``man ./smenu.1`` will do it.