prompt in tcsh

Hi All:
I am not familiar with the shell script.
But I would like to have the command prompt in the following
"look":

[username]@[hostname][current path]>

What should I do in the .login file (or other file)??
Thanks.
 
In your .cshrc (or .tcshrc) set the following:

Code:
set prompt="%n@%M%/>"

Check out man tcsh for more information on how to customize the prompt.
 
Is the command prompt for root different?

in /etc/csh.cshrc I have:
set prompt="%n@%m%/%# "

the other users show the commmand prompt as desired... but root just shows the hostname...

Please advise
 
root uses /etc/csh.cshrc then /root/.cshrc.
By default /root/.cshrc is a hardlink to /.cshrc and defines $prompt as
Code:
        set prompt = "`/bin/hostname -s`# "
Just delete all lines except the first one if you don't plan to use /root/.cshrc.
# sed -i '' '2,$d' /root/.cshrc
 
@blah

I just had to comment out the one line you suggested in root's ~/.cshrc file

It was that easy. Thank you!
 
Actually,previously I was using bash... I had the following setup in /etc/profile

alias ls='ls -G'
alias vi='vim'
alias su='su -'


but these no longer seem to be working now that my shell is tcsh

Any advise? I am really trying to make the switch to tcsh as it is a default shell in freebsd.
 
Ehh... I spoke to soon... I just edited:
/etc/csh.cshrc

With different syntax... SEE:
http://www.decf.berkeley.edu/help/unix/csh/aliases.html

However... there is another issue... I would like to set it so when you press tab 2x in a row it displays all the possibilities instead of just sitting there:

ie) on bash it does what I want:
john:~ john$ cd t
t1/ t2/ t3/ t4/ t5/ t6/

ie) on tcsh it doesn't do what I want:
[john@host ~]>cd t

(there is no suggestions shown after pressing tab 2x)

Please advise...
 
To enable TAB command autocompletion add the following to you .cshrc file:

Code:
set autolist

Otherwise just press Control + d.
 
Thanks!

I actually used
set autolist=ambiguous

Here is my final global configuration for tcsh in:
/etc/csh.cshrc

Code:
# $FreeBSD: src/etc/csh.cshrc,v 1.3.52.1 2008/11/25 02:59:29 kensmith Exp $
#
# System-wide .cshrc file for csh(1).

# EDITS
alias ls ls -G
alias vi vim
alias su su -

alias h         history 25
alias j         jobs -l
alias la        ls -a
alias lf        ls -FA
alias ll        ls -lA

# A righteous umask
umask 22

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)

setenv  EDITOR  vi
setenv  PAGER   more
setenv  BLOCKSIZE       K

if ($?prompt) then
        # An interactive shell -- set some stuff up
        set filec
        set history = 100
        set savehist = 100
        set mail = (/var/mail/$USER)

        # EDITS
        set filec
        set autolist=ambiguous
        set nobeep
        set prompt="[%n@%m %/]%# "

        if ( $?tcsh ) then
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
        endif
endif
 
Don't touch the systems' cshrc. Make your customizations on each user's .cshrc. That way it will be easier to manage updates.

For user vask:
Code:
% vi /home/vask/.cshrc

For root:
Code:
# vi /roo/.cshrc
 
@tangram
For my needs it is easier to use /etc/csh.cshrc beacause:
- I have several users on the server that are all me.
- I want all users to have the same shell environment.
- The ONLY setting that conflicted with the default FreeBSD install was root's prompt, and I just had to comment out that 1 line 1 time to fix that.
- Until I get things settled, I may want to spontaneously change the tcsh environment for all users. This would be a total pain if I want to change it for 20+ users...

Other than that... I am not sure what you mean by managing updates...
 
If you want to have the same environment of every user of course do change the file.

What I meant by managing the updates is if you are on a system with few users it easier to simply changes their individual settings that force changes through a system file; because when you get to the point of upgrading FreeBSD to the new release it's one more item merge in mergemaster.
 
I like to have the current directory prompted, but it often spans more than a line, which I think is pretty annoying. This is my solution:
Code:
set prompt = "%n@%m%# "
set rprompt = "%? %/"

My command prompt looks like this:
Code:
kamikaze@mobileKamikaze>                       0 /home/kamikaze/devel/snapshots
The right side prompt (return code of the last command and current location) is hidden by tcsh, if I type a long command.
Code:
kamikaze@mobileKamikaze> echo "this command is too long"

This is a nice compromise in my opinion.
 
Back
Top