« first day (2178 days earlier)      last day (871 days later) » 

6:59 AM
@louigi600 no idea, these are something to do with Java IIRC? Basically zip files?
 
@Queen k
@Queen k (3 votes)
@Queen k (hesitantly)
 
8:15 AM
@Queen k
 
8:38 AM
Hello can I ask quick question?
 
@Liso probably; the easiest way by far to find out is to try
basic chat etiquette - just ask, instead of asking to ask first
assuming of course your topic is suitable for this room
 
Yeah, its bash related
I'm sorry its my first time here
 
sure, don't worry
 
Ill install peek first, just to record the ouput in gif
 
sounds dubious ... can you summarize your problem in text first?
 
8:42 AM
Sure
So I have this spinner (progress indicator) to show whilst the command is running, though its not really an progress bar all it do just 'spinning' when the command is running. I took the code from here unix.stackexchange.com/questions/225179/… and modify it a little so I can show some info.
By info I mean description
This is the modified version of the script: gist.github.com/L1so/82f7bae295b429acb78399660a7cbab0
So when I tried to run this on my terminal, it fail if the spinner is '-\|/' (if done correctly will make spinning bar, kinda like a propeller). I will attach the gif
 
so it fails to recover the correct position for the info part and only partially overprints?
why does it need to redisplay the info part anyway?
if you want to overprint just the spinner, capture the cursor position just before printing the first spinner and then just return to that position repeatedly and overprint only that part
you seem to be using curses already anyway
Jonas Eberle's answer to the linked question seems to demonstrate how to use it
 
The desired behavior is for info part to stay static and for the spinner to keep spinning until process static
 
yeah so you could just print $narrate once (I guess this is the info message), record the cursor position, then loop: print spinner, return to recorded position until spinning is no longer necessary
 
However if I increment the cnar variable, which is character of information length + $charwidth, its working perfectly.
Yeah $narrate is info message and set to $1
This is the excerpt from the code that changed,
local i=$(((i + $charwidth) % ${#spin}))
local cnar=$((charwidth + ${#narrate})) # Character length + Narrate length
local cnar=$((cnar + 1))
 
8:59 AM
I can't say I understand the width calculation; I would replace it with a curses query to fetch the cursor position because string display width is inherently hard (you have double-width characters, joining characters, etc which throw off calculations)
but by quick inspection you are printing a space between the two %b %b which obviously adds one character
(you only need to make a variable local once; the keyword says the variable is distinct from any variable with the same name outside the function)
 
9:28 AM
I myself dont understand how $i is defined, but $cnar is $charwidth (character width, in this case 1 because length of string "-\|/" is 1), and ${#narrate} is length of info message string, I think pretty self explanatory. So $cnar is length of both info message and spin string.

I also add `echo -en "\033[${cnar}D"` which I believe to echo a backspace (?), by putting $cnar to echo command, I'm trying to backspace/remove current iteration of information and the spinner and.

I hope you get what I mean, also Ill try follow your suggestion.
@tripleee Holy, that was the reason all along
"but by quick inspection you are printing a space between the two %b %b which obviously adds one character" <-- why I haven't realized this ? I have spent at least 3 hours on this to find offending line, and to think it was in printf all along
 
9:49 AM
@Liso echo -en "\033[${cnar}D moves the cursor back to the position indicated by cnar I believe
probably prefer printf just for stylistic points; echo -en raises the blood pressure of many people
@Liso happy to be your rubber duck (-:
 
"yeah so you could just print $narrate once (I guess this is the info message), record the cursor position, then loop: print spinner, return to recorded position until spinning is no longer necessary" I also interested on doing this, so I put $narrate outside while loop ?
 
yeah, basically printf "%s " "$narrate"; whereami=$(tput something); while your condition; do printf "%s%s" "$spinner" "$(tput something else involving $whereami to move the cursor back)"; done
not sure what the tput codes look like for that but the linked question had some good hints
actually you can probably refactor to whereami=$(tput something else involving $(tput something)) and then just echo back the code it produced
getting up to speed with curses is a bit of a learning curve, I don't think I have come across any good beginner resources
the architecture sort of divides the problem space into layers where you have to check back from a different place in the documentation what the concepts mean when you have found the thing you want to use
 
@Queen k
 
Yeah, originally what cross my mind is to print only the spinner and then print the info message alongside it, but I couldn't getting it work, so I ended up with obvious solution, which is to put the info with spinner in the while loop, and then delete and print it again repeatedly.
get it work*
 
 
3 hours later…
1:37 PM
@Queen k
 
 
5 hours later…
 
1 hour later…
7:48 PM
Hi, I was triyng to use this bash script pastebin.com/iMMmbu7t taken from the arch wiki wiki.archlinux.org/title/Environment_variables , but the shell outputs this error messages
What is wrong with the script?
# If user ID is greater than or equal to 1000 & if ~/bin exists and is a directory & if ~/bin is not already in your $PATH
# then export ~/bin to your $PATH.
if [[ $UID -ge 1000 && -d $HOME/bin && -z $(echo $PATH | grep -o $HOME/bin) ]]
then
    export PATH="${PATH}:$HOME/bin"
fi
I don't know almost anything about bash, so I don't even know how to approach the problem
 

« first day (2178 days earlier)      last day (871 days later) »