metal3d / bashsimplecurses Goto Github PK
View Code? Open in Web Editor NEWA simple curses library made in bash to draw terminal interfaces
License: BSD 3-Clause "New" or "Revised" License
A simple curses library made in bash to draw terminal interfaces
License: BSD 3-Clause "New" or "Revised" License
I've made a fully POSIX Shell compliant fork you can take a look at here. While I have no intention of opening a pull request, I do have some interesting features like better ASCII detection, and a bit of a hack that replaces the sleep with a blocking read
timeout, but ends up being a very elegant solution to sneak fully functioning user input into the current codebase. Feel free to take a look.
What steps will reproduce the problem?
1. mettre append_tabbed `cat /proc/meminfo | awk '/MemTotal/ {print
"Total:" $2/1024}'` 2 => Ca marche
2. `cat /proc/meminfo | awk '/MemTotal/ {print "Total:" $2/1024}'`
=> Erreur ./simple_curses.sh: line 202: LASTCOLS/: erreur de syntaxe :
opérande attendue (error token is "/")
What is the expected output? What do you see instead?
Ça aurait facilité le debuggage de voir "erreur pas de second argument à
append_tabbed"
Original issue reported on code.google.com by [email protected]
on 6 Jun 2009 at 2:03
Working on a PR (#65) for this cool project, but wanted to ask about something before charging in with this particular part.
There are quite a few instances of 'if true that something is not equal to nothing', which is unnecessarily taxing to mentally parse. This is why we have the -z
and -n
flags for when something is and is not empty, respectively. You've used this already, but — and this is largely why consistency is important — you've often not, which is confusing. Is there a bizarre nuanced use-case I'm missing?
Incidentally, is there a reason you've used a lot of [
instead of [[
, yet also used [[
? I can only imagine how much this will have confused people reading my old code, because I did the same thing, and I'm now confused reading someone else's for the same reason! Lol In a nut-shell, I found out (through quite a bit of testing) that [[
is far more efficient than [
. I had to change all my code to correct this, which sucked.
Hey everyone,
I'm trying to use this lib, btw is AWESOME, but I have no idea how I can read from the keyboard when I'm showing the information to the user.
e.g: If the user types the key r
change the colors to red.
When running
make test
it comes out really bad looking on Debian 8:
-e Warning - You should install caca-utils or img2txt command
strace(1) shows that /bin/sh is used.
man sh gives the manual page for dash, and that manual page shows that the builtin echo does not support -e as an option.
Setting SHELL=bash as the first line in Makefile makes the output look at expected on Debian 8.
I'm not sure if some creates other problems or if some systems require a full pathname to bash.
I feel silly, but I can't figure out how to change the border colour?
The documentation is really poor and full of English mistakes.
I have tried some emulation terminals such as xshell and putty with same result.
I used the last version of bashsimplecurses.
test.sh
#!/bin/bash
#import library, please check path
#source /usr/lib/simple_curses.sh
source simple_curses.sh
#Then, you must create a "main" function:
main () {
#your code here, you can add some windows, text...
window "title" "red" "50%"
append "Text..."
endwin
}
#then, you can execute loop:
main_loop 1
Hello, I'm trying to create a TUI for my app, yeast. But for this, I need to get user input in the window. Can someone provide me with some help?
Thanks in advance,
shebangcode
Hi,
Firstly, thank you for creating this package, it works like a dream. I have detected a small issue when the simple_curses.sh script tries to determine if UTF-8 is set. The issue maybe related to the version of bash. My LANG is set to en_GB.UTF-8.
$ bash --version
GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
To solve this issue I had to remove the " " marks around the regex on line 91:
- if [[ -z "$ASCIIMODE" && $LANG =~ ".*\.UTF-8" ]] ; then ASCIIMODE=utf8; fi
+ if [[ -z "$ASCIIMODE" && $LANG =~ .*\.UTF-8 ]] ; then ASCIIMODE=utf8; fi
Hopes this helps someone !
Many thanks
Martin
I'm seeing that there are occasions when loading if there's an error with the code that would display that instead of presenting an error I am redirected back to the command prompt.
What steps will reproduce the problem?
1. run any sample on ubuntu 9.04 ( and other ubuntu and ubuntu-like ? )
( fine on fedora mktemp/coreutils-7-2-1.fc11 )
What is the expected output?
The expected output :)
What do you see instead?
An unexpected output :)
mktemp: invalid option -- '-'
Usage: mktemp [-V] | [-dqtu] [-p prefix] [template]
./simple_curses.sh: line 51: $BUFFER: ambiguous redirect
./simple_curses.sh: line 270: $BUFFER: ambiguous redirect
./simple_curses.sh: line 271: $BUFFER: ambiguous redirect
./simple_curses.sh: line 272: $BUFFER: ambiguous redirect
./simple_curses.sh: line 273: $BUFFER: ambiguous redirect
( $BUFFER empty )
What version of the product are you using? On what operating system?
bashsimplecurses-0.0.1
ubuntu 9.04 (x86_64) and mktemp 1.5-9
Please provide any additional information below.
Just change line 23 of simple_curses.sh
Before :
mktemp --tmpdir=${BUFFER_DIR} ${buffername}.XXXXXXXXXX
After :
mktemp -p ${BUFFER_DIR} ${buffername}.XXXXXXXXXX
2 files or just an uggly test on top of simple_curses.sh to choose
alternate syntax of mktemp ?
mktemp --tmpdir=${BUFFER_DIR} ${buffername}.XXXXXXXXXX > /dev/null 2>&1 &&
MKTEMP="mktemp --tmpdir=" || MKTEMP="mktemp -p "
And line 23 :
${MKTEMP}${BUFFER_DIR} ${buffername}.XXXXXXXXXX || { echo "mktemp syntax
error" ; exit ; }
Alternately OS detection should be better ? But kernel dependant...
uname -v | grep -q "Ubuntu" && MKTEMP="mktemp -p" || MKTEMP="mktemp -tmpdir="
Hhhmmm... That's a packaging policy problem !
And thanks for the embeded tty :)
Original issue reported on code.google.com by [email protected]
on 24 Jul 2009 at 12:41
I feel that output needs some TLC. It's exhaustive for usage output. The formatting could do with a tidy. I would suggest looking into writing a man page, at this point, because there seems to be a lot of information to offer. What do you think?
I absolutely recommend a usage format like:
Usage: program [OPTS]
-h, --help - ...
-v, --version - ...
... - ...
... - ...
Some brief information here, if needed.
I might be biased, because I use it in all of my programs, but it's because it's so dang discreet and easy to read! Just as you'd expect from an overview of usage, where the man page ideally goes into more detail. I also ensure the line never exceeds <= 80 columns so that the information is readable; keeping things concise helps.
If you're curious and want to see some examples of what I have in mind, check out some of my projects in both Extra and PerlProjects, like Cito, GLKFU, AutoExec, LSBLK, CSi3, DTP, UbuChk, etc.
First, let me say, this is Awesome - Thank you!
I was wondering if it would be possible to have an option to NOT use xterm, not loop, and just simply run each script once and display the output (while still keeping your incredible output format).
I'm having issues running remotely:
tput: No value for $TERM and no -T specified
and simplifying the environment should solve that, if it's feasible.
Thanks again.
I tried running the examples on my Mac with zsh terminal and it aborts immediately. Then I upgraded ncurses as per one of the other issues suggestions but that didn't change the behavior. Also when run from iTerm2 against a EC2 host, it has a terrible blinking issue with the last cursor line flashing. Seems like a useful tool if I could make it work. Consider including documentation on what OS/dependencies are required.
What steps will reproduce the problem?
1. Try compiling and testing on RHEL5/CentOS5 (in my case 5.6)
2.
3.
What is the expected output? What do you see instead?
i expected to see a windows in terminal, instead i see a blank window with
occasional error ocasionalmessage about improper usage of "mktemp" command in
create_buffer function.
What version of the product are you using? On what operating system?
0.1 alpha
Please provide any additional information below.
For the case of RHEL5/CentOS5 and possibly fedora in RHEL based distro's in
general, mktemp "--tmpdir" is not a valid argument. Instead, please use option
"-p". Once replaced all seemed to work.
Suggestion: please add a funtion that determines the mktemp version or distro
and uses appropriate switch..
Thanks
-ilya
Original issue reported on code.google.com by [email protected]
on 4 May 2011 at 3:08
if you look at the first line, the code for readme.md is
#headerone
it should be
# headerone
This is a new thing with GFM I think.
What steps will reproduce the problem?
1. create a toto.sh file, cut/past the 2 first windows of the sample on the
homepage
2. run
What is the expected output? What do you see instead?
I expect to see the two windows titled "Hostname" and "Memory Usage"
instead I see the two windows (as expected) AND a line with the hostname
at the bottom of the bash window (see attached picture)
What version of the product are you using? On what operating system?
latest from trunk (there is nothing in the downloads section)
Original issue reported on code.google.com by [email protected]
on 6 Jun 2009 at 9:44
Attachments:
Sorry to make an Issue about this — I've nowhere else to really post it.
What's this project's stance on rebasing? I've used Git and GitHub for years, but I've never really rebased in Git before, until now. I'm actually really happy I discovered how to do it, but from looking online, it seems it can be very destructive if not done properly. That's why I'm posting here, to double-check.
I made 3 commits to my local fork of BSC, in preparation for another PR. These changes have not been pushed. I realised I missed something from the 1st commit, so I rebased back to the first commit, made the changes, then amended those changes to the commit. There were no conflicts and everything seemed to work successfully.
My concern is mainly that it'll somehow cause issues for y'all, since I don't yet properly understand rebasing. It strikes me that it'd be fine, because they were local changes and I didn't rebase to or before someone else's changes, but I'm not certain.
I'd rather be annoying and ask, than be quiet and make a mess. 😄
In order of events:
git rebase -i SHA^
git commit --amend
git rebase --continue
Maybe that'll help, in-case I didn't explain clearly.
I've looked online and git-rebase(1), but I either can't find anything concrete, or I frankly just don't understand.
What steps will reproduce the problem?
1. Mettre append "`cal -m`"
2. Observer: on a tout sur une ligne
What is the expected output? What do you see instead?
juin 2009
lu ma me je ve sa di
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
Please provide any additional information below.
Idem avec ls -1, etc...
Original issue reported on code.google.com by [email protected]
on 6 Jun 2009 at 2:08
Here is a little patch to use mktemp if possible, and to revert to a
standard file buffer if SHM is unavailable.
Also, there was a small spelling error on "license".
Original issue reported on code.google.com by [email protected]
on 6 Jun 2009 at 7:02
Attachments:
file wintest.sh line 12 (svn):
append_command "tree -L 2 -C -A ./"
A demo is nicer when we don't need anythig else ;)
Original issue reported on code.google.com by [email protected]
on 12 Jun 2009 at 5:20
I have a simple program I'm building that shows windows, one displays the contents of a file (JSON), and the other displaying the results of a transformation of that JSON (a JQ command). I need an input box somewhere on the screen so the user can dynamically edit the JQ query. I don't see anything in the code that handles input, and my naive approaches with read
caused big problems with the windows.
Any suggestions on how to approach this? I'd be happy to create a PR if I knew what was needed to make this possible.
I have added a new section in init_char() function to allow utf-8 encoding. It
is based con unicode fonts at:
http://www.fileformat.info/info/unicode/block/box_drawing/list.htm
init_chars(){
if [[ "$ASCIIMODE" != "" ]]; then
if [[ "$ASCIIMODE" == "ascii" ]]; then
_TL="+"
_TR="+"
_BL="+"
_BR="+"
_SEPL="+"
_SEPR="+"
_VLINE="|"
_HLINE="-"
fi
if [[ "$ASCIIMODE" == "utf8" ]]; then
_TL="\xE2\x94\x8C"
_TR="\xE2\x94\x90"
_BL="\xE2\x94\x94"
_BR="\xE2\x94\x98"
_SEPL="\xE2\x94\x9C"
_SEPR="\xE2\x94\xA4"
_VLINE="\xE2\x94\x82"
_HLINE="\xE2\x94\x80"
fi
fi
}
Original issue reported on code.google.com by [email protected]
on 7 Sep 2013 at 11:01
im not a big bash scripter, i barely know anything, yet id still like to know how to actually do anything with the choice you can pick in the choices example. ive changed it a little like you see here now:
#i ran: (commandname) list add remove
source /usr/local/lib/simple_curses.sh
declare -a SELECTABLES
while [[ $# -gt 0 ]]; do
# shellcheck disable=SC2034
case "$1" in
-- ) shift; break ;;
* ) SELECTABLES+=("$1"); shift ;;
esac
done
# SELECTABLES=( "$@" )
arraylen=${#SELECTABLES[@]}
selected=0
lastselected=$selected
main(){
window "Would you like to list/add/remove services?" "red" "50%"
local count
count=0
for i in ${SELECTABLES[@]};do
bgcolor="black"
color="blue"
[ "$selected" == "$count" ] && {
bgcolor="blue"
color="red"
}
append "$i" $color $bgcolor
count=$(( count + 1 ))
done
endwin
lastselected=$selected
}
update(){
local ret
local success
read -r -n 1 -s -t 1 ret
success=$?
if [ "$success" -lt 128 ]; then
if [ "$ret" == $'\e' ];then
read -sN2 -r k1
success=$?
ret+=${k1}
fi
case $ret in
[0-9])
selected=$(( $ret - 1 ))
;;
$'\e[A'|$'\e[D')
selected=$(( selected - 1 ))
[ "$selected" -lt "0" ] && selected=$(( arraylen - 1))
;;
$'\e[B'|$'\e[C')
selected=$(( selected + 1 ))
[ "$selected" == "$arraylen" ] && selected="0"
;;
$'\e')
return 255
;;
*)
return $(( $lastselected + 1 ))
;;
esac
fi
return 0
}
main_loop "$@"
i dont understand the update function but i can figure the rest, i just want to know how i can, for example, make a new menu popup when i pick one of the choices?
What steps will reproduce the problem?
1. Wiki => basicTutorial
2. svn checkout https://bashsimplecurses.googlecode.com/svn/trunk/
bashsimplecurses
3. On nous demande un mot de passe
What is the expected output? What do you see instead?
le telechargement direct, sans connection
Please provide any additional information below.
Il suffit de changer https en http ;)
Original issue reported on code.google.com by [email protected]
on 6 Jun 2009 at 2:05
Users should not need to go to the documentation (readthedoc) page to understand and have examples - so, we need a better README file.
Hi,
bash -x one.sh
++ dirname one.sh
. ./../simple_curses.sh
+++ bsc_create_buffer
+++ '[' -d /dev/shm ']'
+++ BUFFER_DIR=/dev/shm
+++ local buffername
+++ [[ '' != '' ]]
+++ buffername=bashsimplecurses
++++ which mktemp
+++ '[' -x /bin/mktemp ']'
+++ mktemp /dev/shm/bashsimplecurses.XXXXXXXXXX
++ BSC_BUFFER=/dev/shm/bashsimplecurses.DzvxjIXkYc
+++ bsc_create_buffer stderr
+++ '[' -d /dev/shm ']'
+++ BUFFER_DIR=/dev/shm
+++ local buffername
+++ [[ stderr != '' ]]
+++ buffername=stderr
++++ which mktemp
+++ '[' -x /bin/mktemp ']'
+++ mktemp /dev/shm/stderr.XXXXXXXXXX
++ BSC_STDERR=/dev/shm/stderr.GRIDOc7Qxb
++ BSC_SIGINT=0
++ trap bsc_on_kill SIGTERM
++ trap bsc_flag_sigint SIGINT
++ _TL='\033(0l\033(B'
++ _TR='\033(0k\033(B'
++ _BL='\033(0m\033(B'
++ _BR='\033(0j\033(B'
++ _SEPL='\033(0t\033(B'
++ _SEPR='\033(0u\033(B'
++ _VLINE='\033(0x\033(B'
++ _HLINE='\033(0q\033(B'
++ _DIAMOND='\033(00\033(B'
++ _BLOCK='\033(01\033(B'
++ _SPINNER=('-' '' '|' '/')
++ [[ ./../simple_curses.sh == \o\n\e.\s\h ]]
main_loop -t 30
parse_args -t 30
BSC_MODE=dashboard
VERBOSE=1
BSC_TITLECROP=0
time=1
[[ 2 -gt 0 ]]
case "$1" in
time=30
shift 2
[[ 0 -gt 0 ]]
bsc_term_init
'[' dashboard == dashboard ']'
tput clear
bsc_init_chars
[[ -z '' ]]
[[ en_US.UTF-8 =~ .*.UTF-8 ]]
BSC_ASCIIMODE=utf8
[[ utf8 != '' ]]
[[ utf8 == \a\s\c\i\i ]]
[[ utf8 == \u\t\f\8 ]]
_TL='\xE2\x94\x8C'
_TR='\xE2\x94\x90'
_BL='\xE2\x94\x94'
_BR='\xE2\x94\x98'
_SEPL='\xE2\x94\x9C'
_SEPR='\xE2\x94\xA4'
_VLINE='\xE2\x94\x82'
_HLINE='\xE2\x94\x80'
_DIAMOND='\xE2\x97\x86'
_BLOCK='\xE2\x96\x88'
++ type -t update
'[' '' == function ']'
update_fn=sleep
'[' dashboard == dashboard ']'
trap 'tput clear' WINCH
true
reset_layout
BSC_COLLFT=0
BSC_COLWIDTH=0
BSC_COLWIDTH_MAX=0
BSC_WLFT=0
BSC_WNDHGT=0
BSC_COLHGT=0
BSC_COLBOT=0
BSC_COLHGT_MAX=0
BSC_NEWWIN_TOP_REQ=0
BSC_NEWWIN_RGT_REQ=0
echo -n ''
rm -f /dev/shm/stderr.GRIDOc7Qxb
'[' dashboard == dashboard ']'
tput clear
tput cup 0 0
main
tput cud 0
++ tput cols
tput cub 183
sigint_check
'[' 0 -eq 1 ']'
cat /dev/shm/bashsimplecurses.DzvxjIXkYc
┌──────────────────────────────────────────────┐┌──────────┐┌──────────┐
│ TP ││ KPI ││ KPI_gxgy │
├──────────────────────────────────────────────┤├──────────┤├──────────┤
│ ││Default_Be││APN_GX_CCR│
└──────────────────────────────────────────────┘│arer_SR_PG││ _SR │
│ W ││(582466/58│
│(142107/14││2470)100.0│
│2098)100.0││ % │
│ 1% ││APN_GX_CCR│
│GTP_Create││ _SR │
│_Session_S││(261837/26│
│ R_PGW ││2881)99.6%│
│(618855/63││APN_GY_CCR│
│0017)98.23││ _SR │
│ % ││(544877/54│
│GTP_Modify││6057)99.78│
│_Bearer_SR││ % │
│ _PGW ││APN_GY_CCR│
│(12207051/││ _SR │
│12211398)9││(194788/19│
│ 9.96% ││5128)99.83│
│GTP_Update││ % │
│_Bearer_SR│└──────────┘
│ _PGW │
│(206178/21│
│0374)98.01│
│ % │
│GTP_Create│
│_Bearer_SR│
│ _PGW │
│(125784/12│
│5936)99.88│
│ % │
└──────────┘
┌──────────────────────────────────────────────┐
│ Monitoring │
├──────────────────────────────────────────────┤
│ │
└──────────────────────────────────────────────┘
'[' 1 -gt 0 ']'
'[' -f /dev/shm/stderr.GRIDOc7Qxb ']'
cat /dev/shm/stderr.GRIDOc7Qxb
window TP cyan 60%
local title
local color
local bgcolor
title=TP
color=cyan
bgcolor=
'[' 1 -eq 2 ']'
case "$BSC_NEWWIN_TOP_REQ$BSC_NEWWIN_RGT_REQ" in
BSC_NEWWIN_TOP_REQ=0
BSC_NEWWIN_RGT_REQ=0
BSC_WNDHGT=0
**++ tput cols
bsc_cols=80**
case $3 in
++ echo 60%
++ sed s/%//
w=60
bsc_cols=48
'[' 48 -lt 3 ']'
BSC_COLWIDTH=48
'[' 48 -gt 0 ']'
BSC_COLWIDTH_MAX=48
++ head -c 48 /dev/zero
++ tr '\0' ' '
BSC_BLANKLINE=' '
BSC_LINEBODY=' '
contentLen=46
BSC_LINEBODY='\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x0\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\E2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2\x94\x80\xE2x94\x80\xE2\x94\x80'
[[ utf8 == \a\s\c\i\i ]]
[[ utf8 == \u\t\f\8 ]]
_TL='\xE2\x94\x8C'
_TR='\xE2\x94\x90'
_BL='\xE2\x94\x94'
_BR='\xE2\x94\x98'
_SEPL='\xE2\x94\x9C'
_SEPR='\xE2\x94\xA4'
_VLINE='\xE2\x94\x82'
_HLINE='\xE2\x94\x80'
_DIAMOND='\xE2\x97\x86'
_BLOCK='\xE2\x96\x88'
++ type -t update
'[' '' == function ']'
update_fn=sleep
'[' dashboard == dashboard ']'
trap 'tput clear' WINCH
true
reset_layout
BSC_COLLFT=0
BSC_COLWIDTH=0
BSC_COLWIDTH_MAX=0
BSC_WLFT=0
BSC_WNDHGT=0
BSC_COLHGT=0
BSC_COLBOT=0
BSC_COLHGT_MAX=0
BSC_NEWWIN_TOP_REQ=0
BSC_NEWWIN_RGT_REQ=0
echo -n ''
rm -f /dev/shm/stderr.tuROv7n8yn
'[' dashboard == dashboard ']'
tput clear
tput cup 0 0
main
tput cud 0
++ tput cols
tput cub 182
sigint_check
'[' 0 -eq 1 ']'
cat /dev/shm/bashsimplecurses.AqWW49t3zZ
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────┐┌─────────────────────────┐┌─────────────────────────┐
│ TP ││ KPI ││ KPI_gxgy │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤├─────────────────────────┤├─────────────────────────┤
│ --------------------------------------------------------------------------------------------------------- ││ Default_Bearer_SR_PGW ││ APN_GX_CCR_SR │
│ S1U SGI S5-SGW S5-PGW DL UL ││ (143701/143690)100.01% ││ (579520/579529)100.0% │
│ --------------------------------------------------------------------------------------------------------- ││GTP_Create_Session_SR_PGW││ APN_GX_CCR_SR │
│ 635.37 2954.20 2442.50 46.06 5396.70 681.43 ││ (606396/617942)98.13% ││ (259688/260532)99.68% │
│ 911.52 6847.43 2437.26 108.99 9284.69 1020.51 ││GTP_Modify_Bearer_SR_PGW ││ APN_GY_CCR_SR │
│ 760.17 5224.95 2008.22 91.76 7233.17 851.93 ││(12829063/12834696)99.96%││ (542715/543871)99.79% │
│ 742.75 5280.52 1846.78 59.15 7127.29 801.90 ││GTP_Update_Bearer_SR_PGW ││ APN_GY_CCR_SR │
│ 0.00 0.00 0.00 0.00 0.00 0.00 ││ (206055/210285)97.99% ││ (188679/189000)99.83% │
│ 785.70 5571.94 2200.49 82.52 7772.43 868.22 ││GTP_Create_Bearer_SR_PGW │└─────────────────────────┘
│ 929.32 6421.38 2230.85 111.18 8652.23 1040.50 ││ (164545/164752)99.87% │
│ 831.10 5752.37 2302.47 85.17 8054.84 916.27 │└─────────────────────────┘
│ 747.86 4889.43 2116.23 61.28 7005.66 809.14 │
│ 0.00 0.00 0.00 0.00 0.00 0.00 │
│ --------------------------------------------------------------------------------------------------------- │
│ Totals ----------- 6343.79 42942.22 17584.80 646.11 60527.01 6989.90 │
│ --------------------------------------------------------------------------------------------------------- │
│ Total UL + DL: 67516.91 │
│ --------------------------------------------------------------------------------------------------------- │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Monitoring │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ CRITICAL (x.xx.xx.xx) ::[SYSLOG] Syslog is Active and not updating for [x.xx.xx.xx] │
│ [SYSLOG] Syslog is Active and updating for [x.xx.xx.xx] [x.xx.xx.xx] │
│ CRITICAL - cdf-1(x.xx.xx.xx) ::[CD] │
│ Response_Message Type Initial ResultCode[xxx] on Gx │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
'[' 1 -gt 0 ']'
'[' -f /dev/shm/stderr.tuROv7n8yn ']'
cat /dev/shm/stderr.tuROv7n8yn
window TP cyan 60%
local title
local color
local bgcolor
title=TP
color=cyan
bgcolor=
'[' 1 -eq 2 ']'
case "$BSC_NEWWIN_TOP_REQ$BSC_NEWWIN_RGT_REQ" in
BSC_NEWWIN_TOP_REQ=0
BSC_NEWWIN_RGT_REQ=0
BSC_WNDHGT=0
**++ tput cols
bsc_cols=182**
case $3 in
++ echo 60%
++ sed s/%//
w=60
bsc_cols=109
'[' 109 -lt 3 ']'
BSC_COLWIDTH=109
'[' 109 -gt 0 ']'
BSC_COLWIDTH_MAX=109
++ head -c 109 /dev/zero
Hi,
Can you create a progress bar ( to copy a file or monitoring memory for
example ) ?
Best regard
David aka hvad
Original issue reported on code.google.com by [email protected]
on 12 Jun 2009 at 8:01
Makefile +30:
which idddmg2txt
Should be:
which img2txt
Original issue reported on code.google.com by [email protected]
on 13 Dec 2013 at 9:19
Hi there! I'm really pleased with bashsimplecurses - thank you!! I've just launched a tool that uses it and we're seeing that MacOS users do not get a full width window when running a script that declares window "100% wide window" "red" "100%"
Instead an 80 char wide window is shown. Since our script displays information that some times is wider than 80 chars, it'd be great if bashsimplecurses supported full width on MacOS.
ohmyzsh
, bash
and sh
cd
into ./bashsimplecurses/examples
macos.sh
with this contents:
#!/bin/bash
. `dirname $0`/../simple_curses.sh
main (){
window "100% wide window" "red" "100%"
append "`date`"
endwin
}
main_loop -t 0.5 "$@"
chmod +x macos.sh&& ./macos.sh
Expected: Window is shown full width of current terminal
Actual: Window is always shown at 80 chars wide, no bigger, no smaller
Related - setting it to 50%
in the script seems to show it at 40 chars wide ( i guess half of the 80 chars it thinks the terminal always is)
Here's a local shell on Ubuntu 20.04/ohmyzsh on the top and and SSH shell on macos/ohmyzsh on the bottom. The first shows a screen ~107 chars wide, the second shows one ~40 chars wide:
Here's the same script running on in a local shell on MacOS:
Hello guys,
here is a little demonstration of what can be done: https://twitter.com/Notfound404__/status/1205977338439241730?s=20
Bash for fun and profit.
If I clone this repo, and create a file e.g. sample.sh
in the same folder, and add a content almost identical to the README sample on it:
#!/bin/bash
source ./simple_curses.sh
main (){
#your code here, you can add some windows, text...
window "title" "color"
append "Text..."
endwin
}
main_loop 1
Then adding execution permission (chmod +x simple_curses.sh
) and executing it I got this:
$ ./sample.sh
Option 1 does not exist
Removing the 1
argument to the main_loop
call in the last line of the script solves the issue.
Is the example in the README wrong/outdated ?
Hey!
I just wanted to be able to exit with a terminal with a 'good' aspect.
What do you think to make the onkill function like this?
on_kill(){
tput cup 0 0 >> $BUFFER
# Erase in-buffer
tput ed >> $BUFFER
cat $BUFFER
rm -rf $BUFFER
exit 0
}
Cheers.
.Yves.
Original issue reported on code.google.com by [email protected]
on 15 Oct 2009 at 1:28
Hi,
I'm building a status script where I'd like lines of text displayed using the same way the latest kernel messages are printed in bashbar.sh but in a column. For some reason text spills below the left windows.
Below is my modified bashbar.sh (basically added 50% to all windows)
#!/bin/bash
. `dirname $0`/simple_curses.sh
main (){
#basic informations, hostname, date,...
window "`hostname`" "red" "50%"
append "`date`"
addsep
append_tabbed "Up since|`uptime | cut -f1 -d"," | sed 's/^ *//' | cut -f3- -d" "`" 2 "|"
append_tabbed "Users:`uptime | cut -f2 -d"," | sed 's/^ *//'| cut -f1 -d" "`" 2
append_tabbed "`awk '{print "Load average:" $1 " " $2 " " $3}' < /proc/loadavg`" 2
endwin
#memory usage
window "Memory usage" "red" "50%"
append_tabbed `cat /proc/meminfo | awk '/MemTotal/ {print "Total:" $2/1024}'` 2
append_tabbed `cat /proc/meminfo | awk '/MemFree/ {print "Used:" $2/1024}'` 2
endwin
col_right
move_up
#5 more used process ordered by cpu and memory usage
window "Processus taking memory and CPU" "green" "50%"
for i in `seq 2 6`; do
append_tabbed "`ps ax -o pid,rss,pcpu,ucmd --sort=-cpu,-rss | sed -n "$i,$i p" | awk '{printf "%s: %smo: %s%%" , $4, $2/1024, $3 }'`" 3
done
endwin
#get dmesg, log it then send to deskbar
window "Last kernel messages" "blue" "50%"
dmesg | tail -n 10 > /dev/shm/deskbar.dmesg
append_file /dev/shm/deskbar.dmesg
rm -f /dev/shm/deskbar.dmesg
endwin
#a special manipulation to get net interfaces and IP
window "Inet interfaces" "grey" "50%"
_ifaces=$(for inet in `ifconfig | cut -f1 -d " " | sed -n "/./ p"`; do ifconfig $inet | awk 'BEGIN{printf "%s", "'"$inet"'"} /adr:/ {printf ":%s\n", $2}'|sed 's/adr://'; done)
for ifac in $_ifaces; do
append_tabbed "$ifac" 2
done
endwin
}
main_loop 0.5
Am I doing something wrong?
Cheers and thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.