Terminal help!

twisty

Registered
I noticed that on opening the terminal, I am getting the prompt [www:~] username% instead of the familiar [localhost:~] username%
A) Any ideas why, and B) Is this real bad? I'd really appreciate some advice.:)
 
testuser stole my thunder -- I was gonna say the bit about the environment variable. For the record, though, I added it to my .login file in my home directory. It does the same thing, just a slightly different way. ;) (Ask if you want more info)

There's a good thread in the HowTo forum about learning Unix. It might be a bit basic, but might not -- I don't know your skill level. The thread is here.
 
When I run hostname in the terminal I get back localhost. Yet I have my hostconfig file set to "HOSTNAME=www.mydomain.org". Is this correct or am I missing something?

Thanks.
SA
 
Sorry, didn't mean to commandeer this thread, but one more thing.

The funny thing is, this is the setup on my TiBook. I shutdown and re-start this computer all of the time. So by your explanation, hostname should return:

www.mydomain.com

This is not the case for me. It returns localhost instead. I wonder why, because the iMac I keep up all the time with the same setup returns the correct www.mydomain.com response when I use hostname. Any ideas why this would be?

Thanks.:)
SA
 
The normal behavior is actually to show the hostname, not 'localhost'. (/etc/hostconfig has always had HOSTNAME=-AUTOMATIC-.) Early versions of OS X had a bug that set the hostname to 'localhost' even when there was a known hostname.

What version of OSX are you running in your Ti Book ?
Maybe upgrading to the latest version of the OS will make it work.

(The prompt doesn't get 'fixed' when you normally upgrade, but it does when you reinstall.)

Another way to set your prompt (with colors) would be:

I put into my .cshrc file the following:

set prompt="\! [%{\033[32m%}%n%{\033[0m%} @%{\033[36m%}%/%{\033[0m%}] : "

32m (green) and 36m (cyan) (you can choose your colors from the chart below)

which gives me:

154 [pm(in green)@(in white)/Users/pm(cyan)] :

The color codes you can use with this ANSI command are the following:

0 Reset colors to 37;40
1 Bold text. In reality, it's not really bold, text is only brighter.
5 Blinking text. Many terminal apps don't support this
7 Reverse video, inverts the background and the foreground colors
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White
40 Black background
41 Red background
42 Green background
43 Yellow background
44 Blue background
45 Magenta background
46 Cyan background
47 White background


Cheers...
 


If you want to display your location in your shell titlebar, you can do the following: (it works with terminal.app, xterm, aterm, eterm)

Create (with an editor like vim) a file named .settitle in your home directory, and write the following commands:

Code:
alias settitle 'echo -n "^[]2;$cwd^G"'
settitle
alias cd 'cd \!*;settitle'
alias pushd 'pushd \!*;settitle'
alias popd 'popd \!*;settitle'

To type the ^[ character into the file type ctrl-v followed by the ESC key.
And the ^G character by pressing ctrl-v followed by ctrl-g.

I had trouble with pico to type the "special characters". Copy-paste doesn't work. So again I repeat, better you use an editor like vim or emacs and don't miss any characters or it will not work.

After you created .settitle, add the following to your ~/.cshrc file:

source ~/.settitle

Now you should get your location in the window title and it will follow you whenever you change directory.

In addition, if you want also to put your username in the titlebar in tcsh, modify the settitle alias in your .settile file like this :

Code:
alias settitle 'echo -n "^[]2;$(USER)@$(HOST) 'dirs'^G"'
This will display name@host followed by the directory stack.

You could also add the following aliases to your collection :

alias psh 'pushd'
alias pop 'popd'
alias cl 'cd \!* ; ls'

And I'm sure that my writing below has been posted in another threads, but just to remember it:

Instead of "Welcome to Darwin" you can make a more exciting message by editing /etc/motd with your unix editor and write your own welcome phrase.

To get the date to show on opening of a new term window in tcsh just type in your .tcshrc or .cshrc file :

date

Finally, I have installed with fink the package:

fortune-mod-9708-2: Database of witticisms

Witticisms that appear before the prompt. After installation, just write in your .cshrc file:

fortune

Well, I must make place for the next one to come. Enjoy and sorry for the long post.


Cheers...
 
That is what is not making sense with my hostname.

What version of OSX are you running in your Ti Book ?

10.1.4. Same as my iMac. Both have the hostconfig file setup to show their respective hostnames. Yet the hostname command only shows the correct hostname on my iMac. It shows localhost on my TiBook.

Seems odd. But I can't trace down the bug and everything is in working order so;)

Thanks.
SA:)
 
testuser,

Thanks for the tip, will try it out. I like that.

buc99,

I'm just fishing here,

1-How many hostconfig files show up in /etc ?

2-Have you tried making a new hostconfig file ?


Cheers...
 
I have the following in /etc:
hostconfig
hostconfig~
hostconfig.old

The only one that looks different is the hostconfig.old, but it should not be read by the system.

Thanks.:)
SA
 
Originally posted by sao
Transparent Dark red. Why?
Because your prompt looks barely readable on the gray background of the messages, and would be worse on white. And because I was curious. :)
 
nkuvu,

I wouldn't have used it with grey or white. You can't read it properly. ;)

Before setting the background color, I naturally tested with several options.

And I settled with dark red, as it looks very fine.

Although it also goes well with 'tinted' dark blue (which I use with aterm).

And even pseudo-transparent (which I use with eterm). Of course, in this last case, I change the desktop background to darker colors.

In xterm, I just decided to use a black background, which it looks good too.


Cheers...
 
testuser,

You tip works perfect. Now my prompt stands like this:

set prompt="\! [%{\033[32m%}%n%{\033[0m%} @%{\033[36m%}%/%{\033[0m%}]%{\033]0;%/\007%} : "

You mention I can subsitute other text into the title in the same way.

Let's say I would like to have the word "hello@" in the titlebar just before:

%{\033]0;%/\007%}

How I would do that? Is this the correct way?

%{\033]0;hello@\007%}%{\033]0;%/\007%}


Cheers...
 
testuser,

It works like a charm. Now my prompt looks like this:

set prompt="\! [%{\033[32m%}%n%{\033[0m%} @%{\033[36m%}%/%{\033[0m%}]%{\033]0;%n@ %/\007%} : "

Thanks again.


Cheers...
 
Back
Top