|
|
I know i've seen this somewhere, but I can't find it.
Is there a way to make my prompt show what dir I'm in?
for example, if i'm in my own subdir dikued, I'd like my
prompt to show:
./dikued:
or if i'm in look., it would say:
./look.:
And so on. Is this possible?
16 responses total.
The answer depends heavily on what shell you use. As far as I know, it's
impossible in sh. In bash (an enhanced sh, which I'm currently using
myself) I use:
PS1='${PWD}$ '
export PS1
I see you use csh, Brenda, & I'm afraid I can't remember how you should
do it. (I remember that it's supposed to be something fairly cumbersome,
and that tcsh (an enhanced csh) makes it much easier.) So maybe remmers
or Valerie or someone will jump in for the csh side of things.
It's been a while since I used csh, so I may get some of the fine
points wrong, but the basic idea is that in your .cshrc file, you
alias 'cd' to something that sets the prompt as well as changing
directory, i.e. something like this:
alias cd 'chdir \@
alias cd 'chdir \!*; set prompt="$CWD <other stuff>"'
The C shell variable CWD always contains the current working directory.
Like Dave says, it's cumbersome. I'd recommend changing shells to
tcsh. It's upward compatible with csh, so your .login and .cshrc files
should continue to work. In addition, including the current directory
in your prompt string is very simple; just include the string %/ in
your prompt definition. Have a look at /u/remmers/.login to see an
example.
Are there any disadvantages to switching to tcsh? Will csh scripts work with tcsh?
Csh scripts should start with "#!/bin/csh", in which case, tcsh should still run them in csh. I can't see why there would be a problem.
Hmm. John, doesn't it have to be $cwd instead of $CWD? (And I presume that the first line you gave wasn't supposed to be there, right?) Brenda, it looks like that basically works, though, with $cwd instead of $CWD (when I just tried it). Rob, in theory (& *most* of the time in practice) csh scripts should run in tcsh (& same comments in all this for sh->bash). The enhanced version is designed to be compatible, & someone worked really hard to make it so. The problem, of course, is in the existence of enhancements, which are by their nature incompatibilities. For example, there are some builtin predefined variables that aren't in csh; if your script happens to rely on the possibility of their being undefined until you set them, watch out. But in general, if it's legal in a csh script, it should work the same way. (I'm operating slightly out of my depth, & anyone who knows better should feel free to correct me if I'm wrong - but I don't think I am. Those more familiar with csh & tcsh certainly may want to provide examples.) The other thing to worry about, of course, is: if I get very used to using tcsh, what am I going to do if I find myself on some benighted system that only supports csh? I don't have much of a feel for how universally available tcsh is; I know it's not on the (SYSV-ish) systems I'm most familiar with. (But the easier command history it provides *is* available with an addon to sh & csh on those systems.)
Um, Steve slipped in with an essential point I'd forgotten for the moment. There is always that.
This response has been erased.
I use tcsh and control-w works for me.
This response has been erased.
I've got "bind emacs" somewhere in my .login, to change the way the tcsh interface handles keystrokes. I just checked again, and it's true for me that ^W deletes the entire line, ESC-BS deletes the word to the left, and ^X-BS makes a cute beep, probably because ^X typically starts the emacs extended command mode. whatever the default key binding was for tcsh was really bugging me, the command history and cursor keys and inserts/overstrikes were not working the way I was expecting to or could get used to.
I think that vi style keys are the default for tcsh. I agree that emacs style keys are much better. Even though, for religious reasons, I cannot support emacs for anything else... <grin>
Hmmm... I use tcsh on a couple of other systems besides Grex. On those I get the emacs key bindings by default; here I get vi. Perhaps the default is a compile-time or configuration option. Does tcsh have a global config file?
ya know, (re#12) I noticed that, too. Long ago when I had an account on mudos and was first introduced to tcsh, the keys were emacs-style. When tcsh first came here, I was happy to switch over. It only took a few hours to get through the manual to find out that there were different key-interface flavours, and only a few more to get them switched...
I think that you can change the default key bindings when compiling, ir in your config files. I am not sure about a global config file...
If you compile tcsh with the author's makefile and other configs, you
get emacs key bindings. tcsh has a lot of options you can set before
you compile; one of them is the default command line edit key
bindings.
Check "config_f.h" for the feature settings. If the following is
undef'd you get emacs bindings:
/*
* VIDEFAULT Make the VI mode editor the default
*/
#define VIDEFAULT
Seems to me that "bindkey -v" will also set all your command line edit
keys to vi-style. ("bind" is an old command that has been repaced by
"bindkey" in the newer versions of tcsh; the latest version is 6.06,
I think).
This response has been erased.
Response not possible - You must register and login before posting.
|
|
- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss