X11 prompt

Hi,

I have an aesthetic question: My X11 prompt looks like this:
80363a2a:/pathtocurrentdir username$
I'd like to simplify it by removing the 9 leading characters. How can I do this?

I'm also interested in suggestions for configuring my .Xdefaults file to make the terminal window easy on the eye and easy to manage. I copied my current settings below.

thanks,
guillaume

xterm*Background: Black
xterm*Foreground: Orange
xterm*borderColor: LightBlue
xterm*borderWidth: 5
xterm*cursorColor: LightBlue
xterm*Curses: True
xterm*pointerShape: arrow
xterm*pointerColor: blue
xterm scrollbarthickness: 10
xterm scrollbarcolor: red
xterm*ScrollBar: True
xterm*scrollBar: on
xterm*rightScrollBar: true
xterm*SaveLines: 1500
xterm*VisualBell: True
xterm*Font: - -courier-bold-r-*-140-

PowerBook G4, Mac OS X (10.4.7)

Posted on Sep 26, 2006 2:00 PM

Reply
11 replies

Sep 26, 2006 9:28 PM in response to gmauger

I would suggest getting rid of all those colors. Courier is a serif typeface, not especially easy on the eyes for scripts and coding and such, the kinds of things that happen in an xterm. So I'd drop that. On my machine the default font, whatever it is, is easy to read.




XTermdeleteIsDEL: True

xterm*geometry: 130x60 40020
xterm*saveLines: 5000
xterm*scrollBar: true

*VT100.translations: #override\
<Key>Prior: scroll-back(1,pages) \n\
<Key>Next: scroll-forw(1,pages)\n\

*Rxvt.translations: #override\
<Key>Prior: scroll-up \n\
<Key>Next: scroll-down\n\

*eterm.translations: #override\
<Key>Prior: scroll-back(1,pages) \n\
<Key>Next: scroll-forw(1,pages)\n\

*Eterm.translations: #override\
<Key>Prior: scroll-back(1,pages) \n\
<Key>Next: scroll-forw(1,pages)\n\

*term.translations: #override\
<Key>Prior: scroll-back(1,pages) \n\
<Key>Next: scroll-forw(1,pages)\n\

*aterm.translations: #override\
<Key>Prior: scroll-back(1,pages) \n\
<Key>Next: scroll-forw(1,pages)\n\

Sep 27, 2006 2:06 PM in response to Jeff Hubbach

Hi Jeff,
Well, we can't leave you hanging when you show such excellent taste! I wasn't going to comment because you don't provide a hint as to where the numbers in the prompt came from. Now I gather it came from my script but oddly that doesn't help. This looks nothing like what I wrote. My current prompt looks like:

[ hostname@ username] Library/init/bash 1221 %

As you can see, there's no colon but there is a hard coded '@' character. Thus I'm guessing that either your scripts aren't set up correctly and my prompt isn't being used or you changed it drastically.

You can view the current prompt string by executing the following command:

echo $PS1

That probably won't show everything but it should be a good start. Please output the results of the command and of the following command:

typeset -f trimpath

In all of my scripts, the prompt is set in the ~/Library/init/bash/prompt script. You should source that script after doing the above. If the prompt changes then we can probably assume that the script wasn't being executed. That's not an uncommon problem with bash; sometimes the ~/Library/init/bash/bashrc has to be sourced from both the ~/.bash_profile and the ~/.bashrc scripts.

The "latest" version of those scripts are at bashrc.tgz. However, I have a confession to make; those scripts haven't been updated in quite a while. The zsh scripts have had several renovations during the same period. I fixed and then stole the Fink functions for prepending and appending elements to a path, which make duplication impossible. I've also added a number of aliases and functions. My zsh scripts are at zsh.tar.gz. It might be worthwhile to get those and use some of the contents in your bash scripts. Very few of the functions use zsh-only syntax.

I think the prompt is really the gem in those scripts. Bash doesn't have the capability of truncating the path to the current working directory to say the last three directories, so I wrote that. Because of that and for other reasons as well, the prompt part of the zsh startup scripts won't work with bash. That has to be pure bash.
--
Gary
~~~~
New York... when civilization falls apart, remember,
we were way ahead of you.
- David Letterman

Sep 27, 2006 2:13 PM in response to Gary Kerbaugh

Gary,

I'm not the original poster, and I haven't posted my prompt, so I'm not sure what you're referring to. This is the output of "echo $PS1"

[\[\033[1;34m\]\u\[\033[0m\]@\[\033[1;32m\]\h\[\033[0m\]]\[\033[1;35m\]~/Backup \[\033[1;31m\]\! \[\033[0m\]$

I haven't changed anything from your script, so it's the same.

My guess, the original poster is being given a very un-user-friendly hostname (which is that nasty numeric string before the : in his prompt) by his ISP.

Thanks for the great scripts, by the way. They're much appreciated.

Sep 27, 2006 2:57 PM in response to Jeff Hubbach

Hi Jeff,
Obviously I don't know what I'm referring to either. My apologies. I saw the reference to my scripts and I remembered the post from before so for some reason without even looking, I answered as if you had made the original post. I just freaked when I thought that my scripts caused a problem and wasn't thinking. Nice prompt though; that does look familiar.

Oh well, I guess we all look like an idiot from time-to-time. This isn't nearly as bad as the time I ... uh, ... nevermind.
--
Gary
~~~~
Make it idiot-proof and someone will build a better idiot.

Sep 28, 2006 2:52 PM in response to gmauger

Hi Guillaume,
My scripts are my attempt to create shell startup scripts like those Wilfredo Sánchez created for tcsh. Sánchez himself created startup scripts for bash I think. There's a set of startup scripts that come with the Fink installation of bash that have his name in them. I'm not sure if the maintainer adapted Sánchez's tcsh scripts or whether Sánchez himself wrote those.

The scripts separate the various tasks that startup scripts do into individual files: environment, aliases, functions and prompt. I provide a few hopefully useful aliases and functions but the most inovative part is the prompt. It's colorful but I think also useful. It gives the history number of each command to make it easy to use history and also gives the return value of the last command if it fails. Instead of giving the entire path to the current working directory, it trims the path to show only the last three directories.

They also include a bashrc that "orchestrates" the execution of the other scripts. If you unpack my tarball in your home directory, it will create a ~/Library/init/bash directory and put the scripts in it. Then you use them by putting the following in your regular bash startup scripts:

. ~/Library/init/bash/bashrc

Naturally you can change anything; it's just nice to have a variety of things from which to start. You can find a truckload of similar examples at dotfiles.com.

Also, you can set the hostname to anything you want by setting the "HOSTNAME" parameter in your /etc/hostconfig file to the explicit fully qualified domain name.
--
Gary
~~~~
The only thing to do with good advice is pass
it on. It is never any use to oneself.
-- Oscar Wilde

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

X11 prompt

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.