GNU Astronomy Utilities - Tasks: task #15138, Color command-line output
You are not allowed to post comments on this tracker with your current authentication level.
task #15138: Color command-line output
Submitter: | Mohammad Akhlaghi <makhlaghi> | ||
Submitted: | Mon 31 Dec 2018 01:09:37 AM UTC | ||
Should Start On: | Mon 31 Dec 2018 12:00:00 AM UTC | Should be Finished on: | Mon 31 Dec 2018 12:00:00 AM UTC |
Category: | All Gnuastro | Priority: | 5 - Normal |
Item Group: | Enhancement | Status: | Postponed |
Privacy: | Public | Percent Complete: | 0% |
Assigned to: | None | Open/Closed: | Open |
Effort: | 0.00 |
Sat 03 Apr 2021 04:51:43 PM UTC, comment #3: |
Mohammad Akhlaghi <makhlaghi>![]() |
Sat 03 Apr 2021 04:16:16 PM UTC, comment #2: Hi! I tried to color code the various outputs by creating functions of different colors that switch the output color.
void red(){
void yellow(){
Then before printing the desired output we can simply call one of these to activate the desired output color. Now to check that the output is printed on terminal and not being piped we can use the "isatty(1)" function where "1" is the parameter that checks that stdout is on terminal.
+static int
will this work for the issue ? Please give suggestions :) |
Abhishek Yadav <abhishek_yadav> |
Mon 31 Dec 2018 01:11:04 AM UTC, comment #1: Another situation to check (for removing color) is in more limited terminals like the internal Emacs terminal (when you run `M-x compile'). |
Mohammad Akhlaghi <makhlaghi>![]() |
Mon 31 Dec 2018 01:09:37 AM UTC, original submission:
In many scenarios of Gnuastro's programs, it can be really helpful if the output text (on the command-line) is color coded. For example the new `--verify' option to the Fits program.
Fortunately all modern terminal emulators (even on Windows), follow the same ANSI escape codes to define colors (summary, or full Wikipedia description.
So the job isn't too hard, it just needs some checks (to remove when the output isn't being directly printed on a terminal, for example being piped). We should look to see how `ls' (in GNU Coreutils) does it. |
Mohammad Akhlaghi <makhlaghi>![]() |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Thanks a lot Abhishek! This seems like a workable solution, nice work! I think you are ready to try it out in practice in your own development branch (if you haven't done so already).
Here are some commands that can help in the test (using one of the FITS images created during 'make check', and the 'astfits' executable that is in the build directory, so you can play with the source):
You can now use the two calls with '--verify' for test-running your implementation.
Have you created a branch and a fork for your development? If not, see Gnuastro's forking tutorial.
I really look forward to see your fork and testing it! We can then find a generalize-able way to put this in the library and use it in many other Gnuastro programs too.
P.S. Savannah's interface is a little old, but it does have a simple Markup that can make your code blocks look more clear (like the case above). The link to this markup page is just on top of the comment-writing box (to the left of the "Preview" button).