Skip to content

minimal ncurses menu for c programs and shell scripts.

License

Notifications You must be signed in to change notification settings

hhhhhhhhhn/mmenu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mmenu - minimal menu

Small ncurses menu for c programs and shell scripts, similar to suckless' dmenu.

For shell scripts

It reads the contents of stdin and changes them to stdout. It takes the second argument as the prompt, and if the third one is set to "t" or "true", it will write the index of the line instead of the line itself. An example might look like:

ls -1 --color=never | mmenu "select file: " | xargs less -R 

For C programs

The main (mmenu) function takes 3 inputs, the options, (similar to argv), the length of the options (similar to argc), and the prompt to be asked (a string). The return value is the index of the element chosen, or -1 in the case of none. The -lncurses flag is required at compilation. An example may look like:

#include "mmenu.h"

int main() {
	char* options[5] = {"Zero", "One", "Two", "Three", "Four"};
	int chosen = mmenu(options, 5, "Please choose an option: ");
	if(chosen == -1) exit(1);
	printf("You chose: %s", options[chosen]);
}

About

minimal ncurses menu for c programs and shell scripts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published