LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   interface in shell (bash scripting) (https://www.linuxquestions.org/questions/programming-9/interface-in-shell-bash-scripting-886884/)

roekoe 06-17-2011 09:01 AM

interface in shell (bash scripting)
 
Hello everyone,

I want to create an interface in bash just like the interface from Mysql in shell, with the borders around the text. I´ve tried to search on google but all it comes up with is how to make graphical user interfaces for scripts.

any help is appreciated.

Skaperen 06-17-2011 09:09 AM

I wrote a separate awk script to do this, which I often call from bash scripts as a command. It only draws one box layer around the text piped into it. If you want more, like a spreadsheet grid, maybe this would at least be a good starting example.
Code:

#!/usr/bin/gawk -f
BEGIN {
    w=1;
}
{
    a[NR]=$0;
    l=length($0);
    if(w<l)w=l;
}
END {
    b="";
    for(i=1;i<=w;++i)b=b "-";
    print "+-" b "-+";
    for(i=1;i<=NR;++i){
        m=a[i];
        for(j=length(m);j<w;++j)m=m " ";
        print "| " m " |";
    }
    print "+-" b "-+";
}


MTK358 06-17-2011 09:52 AM

This might not be exactly what you're looking for, but what about dialog (http://en.wikipedia.org/wiki/Dialog_(software))?

roekoe 06-18-2011 08:11 AM

Thanks for the information, now I got something to work with.

theNbomr 06-19-2011 10:08 AM

This interesting use of ncurses might be of interest to you.
--- rod.


All times are GMT -5. The time now is 12:43 PM.