Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Hephaestus

macrumors 6502
Original poster
Apr 4, 2010
356
13
I've been programming a few months now as part of my degree, using C. I use Xcode on my Macbook but like to compile the code in terminal since the one in the programme is too obtrusive for me, I don't like the white background and all the other text.

I have one question. Does anyone know how to make all the unnecessary information in Terminal go away. For example when I run my UEXE file I always get this message at the top of the programme.


Last login: Tue Mar 20 12:11:40 on abcdefg
/Users/Johndoe/Desktop/Project/build/Debug/Project ; exit;
bayley-111-52:~ Johndoe$ /Users/Johndoe/Docs/Project/build/Debug/Project ; exit;


I want to remove all this so when I run my programme, all I see is my programme. I dislike all this extra information. I've been searching around for help but am struggling to solve this.

Thanks
 
I presume you are running your program by double-clicking on an icon which starts the shell and then invokes your program?

Yeah thats right right. I'm double clicking the executable file in the debug folder inside the project folder.
 
I don't have XCode in front of me (I'm on a PC at work) so I can't be of much further help at this point, but hopefully someone can chime in. I think that there should be a way to change (or create) a startup shortcut that opens a new window to start your program directly without showing the shell login information.
 
Maybe customizing your bash prompt to something short does what you want. I'm not sure what you want to do is entirely doable with bash. You could try alternative shells, but I'm not an expert on this.
 
Maybe customizing your bash prompt to something short does what you want. I'm not sure what you want to do is entirely doable with bash. You could try alternative shells, but I'm not an expert on this.

I've just done some research on that and it seems that this will simply change the prompt every time you open Terminal, not remove it. That isn't exactly what I'm after. What I want is when you open a programme, only the programme is displayed. Surely there must be a way to do this?

I just discovered that if you click 'clear scrollback' in the 'view' setting in Terminal it gets rid of all the text. When you open the programme again however it reappears so with this method you need to clear the scrollback every time you open a programme; which eliminates the point. Anyone know if there is a way to permanently disable the scrollback?
 
Last edited by a moderator:
Try using Terminal more the way it was designed.

Code:
Open Terminal.
type "clear" hit enter
drag and drop the executable to Terminal.app to get its name (or type it in).
hit enter
get output
type "clear" hit enter.

The only extraneous output will be the bash prompt and the output of the executable.

B
 
Your program itself could try to clear the screen, but there's not really a good, platform-independent way to do this.

I am not sure what, exactly, is making you sad. Normally one opens a terminal on their own then runs a binary from there. In that case, they already saw the info when the terminal opened and they're used to it, and when they run your program they expect its output to start on the next line. This is just how things work. Clearing users' screens is a bit rude, and there really isn't a need.

If you really want to clear a screen there are ways to do it. You can run cls on some systems and it might do what you want. You could print some newlines to try to get any previous output to be above the current view.

Anyway, don't do this. It's not necessary and will likely cause more hurt than help. If your app needs to "own" the terminal, you should probably be using a library like ncurses which will surely provide you with a method to clear the screen.

-Lee
 
Your program itself could try to clear the screen, but there's not really a good, platform-independent way to do this.

I am not sure what, exactly, is making you sad. Normally one opens a terminal on their own then runs a binary from there. In that case, they already saw the info when the terminal opened and they're used to it, and when they run your program they expect its output to start on the next line. This is just how things work. Clearing users' screens is a bit rude, and there really isn't a need.

If you really want to clear a screen there are ways to do it. You can run cls on some systems and it might do what you want. You could print some newlines to try to get any previous output to be above the current view.

Anyway, don't do this. It's not necessary and will likely cause more hurt than help. If your app needs to "own" the terminal, you should probably be using a library like ncurses which will surely provide you with a method to clear the screen.

-Lee

I just dislike it because it looks messy. I'm working on my own laptop so not sure what you mean about being rude? Its just unattractive when I run a programme to test it and its loaded with 4 lines of irrelevant text and symbols. I was working with a friend who was using Visual C++ on his PC and the compiler simply loaded the programme and displayed it. I'm very surprised that it appears difficult to achieve this.
 
I just dislike it because it looks messy. I'm working on my own laptop so not sure what you mean about being rude? Its just unattractive when I run a programme to test it and its loaded with 4 lines of irrelevant text and symbols. I was working with a friend who was using Visual C++ on his PC and the compiler simply loaded the programme and displayed it. I'm very surprised that it appears difficult to achieve this.

I was saying that if your program itself cleared the screen when it started that might be rude for users. Obviously it's not rude to yourself.

A more effective way to deal with this might be to simply open a terminal, and run the program as balmw described above. After each run of your program you can hit the up arrow to bring the command back up and run it again. If you'd prefer, you could have a line like:
clear; /Path/To/My/Program
so it will clear the screen before each run. Then you can run, up arrow, run, etc. ad infinitum.

I think the reason it seems "hard" is that you're using an unusual method of launching the program. Rarely will a unix executable be run by double-clicking in finder. It will be more common that someone will already have a terminal prompt open and just run the program, expecting output to start on the next line. That is normal behavior of a command-line program. If you run it this way it may be more pleasant for you.

-Lee
 
I think the reason it seems "hard" is that you're using an unusual method of launching the program. Rarely will a unix executable be run by double-clicking in finder.

Plus, the "extraneous" data can actually be useful so you know that the Terminal is working correctly and the proper executable was launched if the executable itself doesn't give any output up front or gets hung somehow.

B
 
Ok thanks for the info, I'll mess around with it for a while and see what happens.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.