Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-02-2006, 12:50 PM   #1
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Lightbulb Need help or suggestions on drawing a cmd-line GUI in bash.

I'm not sure entirely how to explain what I'm trying to do, but in a nutshell:
I have a list of text files, each containing a couple of snippets of information. I'd like to create a shell script which reads all of those files and prints them out in a coherent format, wherein the user can choose a file to edit, delete, etc...

I'm envisioning something akin to the pine interface - a box, a list of choices inside of the box, and the user can use arrow keys to choose an item and a command or two to choose what they'd like to do with it.

Most of this I can handle, although I know the final product won't be quite so slick-looking. do I change what's displayed in one area without redrawing the whole screen? Like, if the user scrolls down the list of items, all I want to move is the list of items. Using up their PuTTy scrollback buffer to redisplay the entire window each time one line changes seems really inelegant.

I've seen someone do this in C ...I'd like to do this in Bash if at all possible.

Old 02-02-2006, 01:07 PM   #2
Senior Member
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
have you checked out ncurses?
Old 02-02-2006, 01:18 PM   #3
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
If you want to do this in only Bash then AFAIK the closest you can get to anything resembling a menu is select statements and tput for wipes. If you allow external apps check out dialog.
Old 02-02-2006, 01:20 PM   #4
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Original Poster
Rep: Reputation: 30
Hmm, I'd only previously heard of ncurses in the way of resolving dependancies, but from what I just gleaned from a google search, it looks promising.

Thank you, I appreciate the pointer!
Old 02-03-2006, 12:37 AM   #5
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,902

Rep: Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590Reputation: 590
dialog is what you want. It uses the ncurses libs.
Old 02-03-2006, 10:35 AM   #6
Senior Member
Registered: Mar 2004
Location: england
Distribution: NetBSD, Void, Debian, Mint, Ubuntu, Puppy, Raspbian
Posts: 3,487

Rep: Reputation: 233Reputation: 233Reputation: 233
here's a silly script of mine
i usually ls into xless and cut and paste.


# read stdin and do $1 to the first thing on a
# received line.
# designed for pasting in X.
# eg: if you have a list of files you
# want to edit using gvim.
# open an xterm and type:
# wr gvim
# then copy and paste using X into the terminal

msg="#------------------\n# What do you want to:$* ?"
print -u2 -- $msg
while read thing rest; do

    [ "$thing" != "" ] && eval $* $thing
    print -u2 -- $msg
    sleep 1                                 # we don't like fast infinite loops!



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
drawing line in php on web page pranith Programming 6 06-21-2005 04:14 AM
Easy way to install GUI from cmd line? r%t Mandriva 2 12-22-2003 02:12 AM
Best distro for cmd-line webserver Seft Linux - Newbie 4 11-15-2003 03:32 AM
booting then to cmd line..... Why not to GUI?? Ax787 Linux - Newbie 1 10-28-2003 10:45 AM
Drawing a line chr15t0 Linux - General 1 03-27-2003 03:36 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:06 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration