Changing your tcsh prompt

Changing your tcsh prompt

see also Shells

The research for this
article was done by Hydro- and huey_ on Undernet’s #FreeBSD IRC channel.

man tcsh

Hydro- told me where to look.  If you want the prompt set each time you login,
put the code in either .tcshrc or .login in your home directory.
  But my opinion is that you should use the shell-specific file for shell-specific
things.  In other words, I recommend .tcsh over .login.

.login

First, go to your home directory:

If you want a prompt that looks like:

[user@host] current/path(cmnd#)

Then use:

set prompt="%B[%n@%m]%b%/(%h): "

Changing your tcsh prompt (added on 20 May 2000)

Andrew Zavjalov writes in with this stuff about prompts:

  1. A nice prompt in xterm only! (or in smart ssh client, f.e. TeraTermPro):

    set ellipsis set prompt=’%{^[]0;%n@%m, %.03, %P, CODE=%?^G%}%B%n%b@%m%B:%b%.02> ‘

    ^[ – Esc ^G – \007

    This prompt will change xterm title every time.

    Another prompt (huge and not useful): #set prompt=’%{^[]0;%n@%m, %.03, %P,
    CODE=%?^G%}%{‘"`echotc AF 2`"’%}%B%n%b%{‘"`echotc AF
    1`"’%}@%{‘"`echotc AF 3`"’%}%m%B%{‘"`echotc AF
    5`"’%}:%{‘"`echotc AF 7`"’%}%b%.02> ‘

  2. timing… set time=(1 ‘%Uu %Ss %E %P %X+%Dk (max %Mk) %I+%Oio %Fpf(%Rmpf)+%Ww %rr+%ss
    SIG: %k %w+%c’)

    Then try to execute long process (longer then 1 second and not `sleep 2` :-).

  3. set savehist=(1000 merge)

    merge!

  4. report about logging on/logging off other people…
    set log set watch=(1 any any) set who="%n@%M (%a)"
  5. TAB-complete… more useful: bindkey ^I complete-word-fwd
  6. And about ls (don’t forget about "set term=xterm-color" if you use teraterm,
    scrt etc.):

    alias ll colorls -lAFG alias l colorls -aFG setenv LSCOLORS
    "3x5x2x3x1x464301060203"

    (colorls in ports/packages)

    I use only colorls in shell.

1 thought on “Changing your tcsh prompt”

  1. I’ve set a little script up in /etc/csh.cshrc which is the global file that controls all users. It can be overridden by the user’s own .cshrc or .tcshrc.

    The script itself sets up a prompt with my name, hostname, path (using ~ instead of your home directory where appropriate), the current time and the > or # prompt depending on whether you’re root or not. What I did was to make the script set the user@hostname bold if you’re root:

    #Set the prompt for all users, only make it bolder for root
    if ($uid == 0) then
    set prompt="%B[root@%m]%b%~ %T %# "
    else
    set prompt="[%n@%m]%~ %T %# "
    endif

    Cheers,
    Aled.

    [%sig%]

Leave a Comment

Scroll to Top