You are not logged in.

#1 2012-11-27 17:32:38

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 3,424
Website

First world problem question: Separating terminal output

So I was up one night not sleeping when suddenly a thought popped into my head: I don't know of any good way to separate the output of command line applications in a terminal window.

This situation comes up usually when I'm programming. I'll compile and see a bunch of errors. I'll make some changes and compile again. When I see more error messages appear, I want to scroll up to the first error that occured, but it's haaard because the error messages blend together with the messages from the last time I tried to compile. So then I'll enter a bunch of new lines like a doinkus and run make again.

Sometimes I try clearing the screen with Ctrl-L, but that always make me hesitant. Will it enter new lines, will it simply shift the text up to the top of the window, or will it erase a screen's worth of output? Does it change depending on whether I'm in TTY, urxvt, or tmux? I don't know. Whatever.

I have some immediate ideas about how to separate output, such as printing a horizontal line of dashes when a command exits, or maybe using color.

I have the feeling some enterprising Arch Linux user has figured out a better way. Do you have a special way of separating terminal output?

Offline

#2 2012-11-27 18:08:09

Homy
Member
Registered: 2012-11-27
Posts: 3

Re: First world problem question: Separating terminal output

There are many ways to do that.

I use for example "reset"  that initialize my terminal again, so all output is really cleared.

Or you open two terminals,
First - you compile your code with

gcc helloworld.c  >debugg 2>&1

Second- you watch your output

watch cat debugg

Or get creative smile

Offline

#3 2012-11-27 18:10:19

Lord Bo
Member
Registered: 2012-11-11
Posts: 151

Re: First world problem question: Separating terminal output

Hm, maybe I don't understand you correctly. Why don't you redirect stdout or stderr to a file, e.g. for stderr: make blub 2> errors.txt .

Offline

#4 2012-11-27 18:28:39

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 18,354
Website

Re: First world problem question: Separating terminal output

Simple hack:
tmux + a function:

next() { printf "%s\n" "-------------------------------------------------------" && clear ; }

Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Offline

#5 2012-11-27 21:14:15

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,013

Re: First world problem question: Separating terminal output

I have my PS1 print a blank line, the time in colour on it's own line and then the pwd + prompt.
Makes it easier to find the start of each command I ran.

PS1='\n\[\033[0;33m\]\D{%l:%M:%S %P}\n\[\033[01;34m\] [ \[\033[01;37m\]\W\[\033[01;34m\] ]\[\033[1;33m\]$\[\033[00m\] '
 6:17:58 am
 [ ~ ]$ echo hello
hello

 7:10:03 am
 [ ~ ]$ echo world
world

 7:10:08 am
 [ ~ ]$ 

You're just jealous because the voices only talk to me.

Offline

#6 2012-11-27 21:18:06

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,535
Website

Re: First world problem question: Separating terminal output

make | less

*I actually just pulled this out of my *(&^, but with a make-output syntax file and a source-highlight lesspipe, this could be pretty useful.  Time to go write a syntax file.

Last edited by Trilby (2012-11-27 21:19:25)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#7 2012-11-27 21:22:17

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 3,424
Website

Re: First world problem question: Separating terminal output

moetunes wrote:

I have my PS1 print a blank line, the time in colour on it's own line and then the pwd + prompt.
Makes it easier to find the start of each command I ran.

Woah. Even though I'll lose some vertical space with each command, I think I'm gonna have to try that. yikes

I also think the idea of splitting up the error information into a separate terminal window.

Aw, heck, these are all cool ideas.

Offline

#8 2012-11-27 21:23:01

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 3,424
Website

Re: First world problem question: Separating terminal output

Trilby wrote:

make | less

Does this work? Will "less" capture all of the lines, including the error messages?

Offline

#9 2012-11-27 21:40:39

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,535
Website

Re: First world problem question: Separating terminal output

It works here.  Although I don't think I'll be making a source-highlight syntax file.  I love source-highlight, but it's a bit of a PITA to write configs for.

EDIT: OOPS! no it doesn't.  It all only showed because it gets dumped over the same terminal.  If I try to scroll around it vanishes.  But a slightly less simple `make 2>&1 | less` should do.

Last edited by Trilby (2012-11-27 21:41:58)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#10 2012-11-28 03:38:23

bsilbaugh
Member
From: Maryland, USA
Registered: 2011-11-15
Posts: 141

Re: First world problem question: Separating terminal output

In regards to handling compiler error messages, there are a couple of solutions that helped me:

  1. Color GCC: This will add some color to GCC compiler error messages so that they are easier to visually parse.

  2. Syntastic: If you're a Vim user, you can use this to run a syntax check on a source file while you have it opened. Any found syntax errors are then highlighted in the buffer, and the corresponding compiler error message is printed below the buffer. This will work with either console vim, or gvim. This plugin was a HUGE time saver for me. (I expect that emacs has a similar plugin.)

In regards to clearing a terminal buffer, the following works in urxvt:

echo -ne '\033c'

In my bashrc file, I just created an alias,

alias cls="echo -ne '\033c'"

and run it whenever I want to clear the terminal buffer.

I'm not sure if this is what you were looking for, but I hope it helps.

Last edited by bsilbaugh (2012-11-28 03:40:05)


- Good judgement comes from experience; experience comes from bad judgement. -- Mark Twain
- There's a remedy for everything but death. -- The wise fool, Sancho Panza
- The purpose of a system is what it does. -- Anthony Stafford Beer

Offline

#11 2012-11-28 04:47:53

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 3,424
Website

Re: First world problem question: Separating terminal output

bsilbaugh wrote:

In regards to clearing a terminal buffer, the following works in urxvt:

echo -ne '\033c'

That's great! Thanks to you, I added it to my bashrc file. I called mine "wipe". big_smile Next I'll have to look into getting it to work with tmux.

Offline

#12 2012-12-27 02:03:55

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 3,424
Website

Re: First world problem question: Separating terminal output

moetunes wrote:

I have my PS1 print a blank line, the time in colour on it's own line and then the pwd + prompt.
Makes it easier to find the start of each command I ran.

PS1='\n\[\033[0;33m\]\D{%l:%M:%S %P}\n\[\033[01;34m\] [ \[\033[01;37m\]\W\[\033[01;34m\] ]\[\033[1;33m\]$\[\033[00m\] '

I just wanted to say that making this my PS1 was one of the best things I've ever done on my computer. I was going to modify to make it more "mine", but it was completely unnecessary. It's just perfect the way it is.

Offline

#13 2012-12-27 02:25:23

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 5,661

Re: First world problem question: Separating terminal output

I used to use:

make 2>&1 | tee make.out

However, I don't really compile stuff much now - moving the gnu/linux has made it easy to be lazy - but I assume it would work here as well.

EDIT: Obviously my ignorance but why is this a "First world problem question"? (Unless the idea is that it is not a problem which would occur outside the "first world" due to a lack of technology. But that seems both implausible as an interpretation and inaccurate as a claim...)

Last edited by cfr (2012-12-27 02:28:55)


How To Ask Questions The Smart Way | Help Vampires

Arch Linux | x86_64 | GPT | EFI boot | grub2 | systemd | LVM2 on LUKS
Lenovo x121e | Intel(R) Core(TM) i3-2367M CPU @ 1.40GHz GenuineIntel | Intel Centrino Wireless-N 1000 | US keyboard with Euro | 320G 7200 RPM Seagate HDD

Offline

#14 2012-12-27 14:30:23

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 3,424
Website

Re: First world problem question: Separating terminal output

cfr wrote:

Obviously my ignorance but why is this a "First world problem question"? (Unless the idea is that it is not a problem which would occur outside the "first world" due to a lack of technology. But that seems both implausible as an interpretation and inaccurate as a claim...)

It was supposed to be a funny and attention grabbing title. smile

My thought was that so many people on this forum have serious computer problems, such as webcams not working, regressions when updating, and installation troubles, that my problem is much much less serious: When I press the enter key a lot inbetween commands my pinky gets tiiired. It reminded me of other "first world problems", such as "I forgot to bring my phone with me when I went to poop and I was bored the entire time" and "None of my 3 wiper speeds are proportional to the amount of rain I'm in". sad

Offline

Board footer

Powered by FluxBB