Displaying Other Types of Information

Your prompt or window title can be used to display other kinds of information, such as your username. You can also set the text of an xterm window's icon so that useful information is displayed even when the window is iconified. This section discusses some of the possibilities.

Displaying the Username

If you have multiple accounts under different logins, you may find it useful to display the current username in your prompt or window title.

To display your name in the prompt with tcsh, just include %n in your prompt variable setting. The following example produces a prompt of name@host: dir%:

set prompt = "%n@%m:%~% "

To display the name in the prompt with csh, modify your setprompt alias to reference the appropriate environment variable (probably USER or LOGNAME, depending on what kind of system you have; we will use USER here). For example, to display the username and the last component of the directory name, use a definition of setprompt that looks like this:

alias setprompt 'set prompt = "${USER} $cwd:t% "'

To put the username in the window title, modify the settitle alias in your .settitle file. The following definition displays name@host followed by the directory stack:

alias settitle 'echo -n "ESC]2;${USER}@'hostname' 'dirs'CTRL-G"'

In tcsh, the hostname is available in the HOST environment variable. Referencing a variable is more efficient than running hostname, so the alias can be rewritten as follows:

alias settitle 'echo -n "ESC]2;${USER}@${HOST} ...

Get Using csh & tcsh now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.