- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- PS1 for C Shell
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 02:33 AM
тАО06-08-2006 02:33 AM
What is the equivalent for
export PS1="`tput bold``uname -n``tput rmso` \$PWD > "
in C Shell ? I want to set this same variable for C Shell. I use this in /etc/profile (or)and .profile.
Thanks,
Arun
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 02:47 AM
тАО06-08-2006 02:47 AM
Re: PS1 for C Shell
Here is a cut and paste. I belive cshell uses different file names, not .profile.
Its been a while.
open snip....
University Computing Services
A brief guide to using UNIX on UCS computers at Florida State University.
If you need additional help, contact the User Services Helpdesk.
UNIX shells
A Unix shell is a program that interprets user-issued commands and passes them to the operating system kernel for execution. Unix provides three shells, the Bourne shell, the Korn shell, and the C shell. Unix utilities are available under each type of shell. Shell commands and capabilities differ, but each type of shell provides features such as parameter processing, variable definition, and loop structures.
The Bourne shell (sh) is named for its author and is distributed with AT&T Unix system software. The Korn shell (ksh, also known as the K shell) is also named after its author; it is similar to the Bourne shell, but has many extended features. The C shell (csh) was developed at the University of California at Berkeley and has a syntax similar to that of the C programming language; it also has many extended features, but it is not compatible with the Bourne shell. All three shells have lengthy on-line manual pages that describe details that are not included here. For example, the manual pages for the Korn shell can be requested with
% man ksh
In this manual, the character % is shown as the interactive prompt from the C shell, and $ as the prompt from the Korn shell or Bourne shell. The C shell prompt is normally shown in examples, unless the topic is specific to another shell.
Changing the Shell
When you log in to Unix, a shell process will start up for interactive input. You have a choice of working under any of the three command interpreters.
Your login shell type is stored in the system password file. The default for new users is the Bourne shell, sh, but it can be changed with the chsh (change shell) command. chsh does not affect your current session, but takes effect the next time you log in. If you want subsequent logins to be under a C shell, Korn shell, or Bourne shell, the commands are, respectively,
$ chsh loginname /bin/csh
% chsh loginname /bin/ksh
% chsh loginname /bin/sh
where loginname is the user name you are logged in under.
Regardless of which shell you are working under, you can invoke new shell processes with the command csh, ksh, or sh.
Recalling Commands
Korn Shell Command History
The Korn shell allows the user to edit and reissue previous commands, using a special mode similar to a one-line vi editor. The terminal must be set up to run the editor, and you must also set the value of the EDITOR variable in .profile to /usr/bin/vi . The vi editor is described in Appendix A.
At the Korn shell prompt you can press the ESCAPE key to enter command editing mode. The 'k' key moves you "up" through previous commands, and the 'j' key moves you back "down" to more recent commands. You can insert and change the text of the command with a subset of the vi commands. When you are finished editing the command, yyyyyyyyyyyyyexecutes it.
C Shell Command History
The C shell history mechanism keeps track of shell commands issued and allows you to list and reissue previous commands. To display the command history list, enter
% history n
The parameter n is optional and specifies the number of commands to be displayed.
You can display your history list in reverse order, starting at the most recent command, by typing
% history -r
A command can be recalled by number with
% !n
where n is the event number (or use !-n for the nth comand from the most recent). To reissue the last command, type
% !!
You can also specify commands by name. For example,
% !cf77
will issue the most recent command that began with cf77.
You can modify a recent command before re-executing it. For a full explanation, see the History Substitution chapter of the man page for csh.
Tailoring the Environment
Unix shells allow users to tailor their working environments in many ways. Commands can be placed in scripts that are executed automatically at log in for purposes such as defining command aliases and environment variables and execution of certain programs. See Chapter 4 for more information about shell scripts.
The Bourne Shell and Korn Shell .profile Files
The general environment for the Bourne shell and Korn shell is established by the system administrator in the file /etc/profile, which is executed whenever a user logs in under these shells.
A user's private profile can be placed in a file named .profile in his home directory.
Both the Bourne and Korn shells allow the user to define shell functions (see examples below). The string $* indicates where the function parameters should be placed. The Korn shell also permits command aliases, but the Bourne shell does not. Comments can be preceded with the # character.
Environment changes must be exported with the export command in order to affect subshells.
Sample .profile File
# This file is similar to the default .profile file on
# the Y-MP, which users are free to modify. This file is
# read upon the first invocation of sh or ksh.
#
# Some shell functions that define new versions of ls:
#
ls() { /bin/ls -C $*; }
lf() { /bin/ls -CF $*; }
dir() { echo " ";pwd;echo " ";lf;echo " "; }
#
# Aliases work only under Korn shell
#
alias up="cd .."
alias ty='cat'
alias bye='exit'
#
# Default search path
#
PATH=.:$HOME/bin:/bin:/usr/bin:/usr/ucb:/usr/local/bin
export PATH
#
# Define other environment variables
#
EDITOR=/usr/bin/vi; export EDITOR
#
# Set prompt to ymp$:
#
PS1="`uname -n`$ "; export PS1
#
# Set default file permission to exclude other:rw and group:w
#
umask 026
Every user is provided a default .profile file, but is free to modify it to suit his or her preferences. However, users should be careful about modifying the profile, since unexpected things can occur if the wrong commands are inserted.
Under the Bourne or Korn shell you can implement commands in .profile so that they affect the current environment with
$ . .profile
C Shell .login and .cshrc Files
The general environment for the C shell is established by the system administrator in the file /etc/cshrc, which is executed whenever a user logs in under the C shell. Users can modify their own environments by placing commands in scripts named .cshrc and .login in their home directories. The file .logout in the home directory can be created to store commands to be executed each time the user logs out.
The file .cshrc is executed each time a new C shell process is created. It affects any child processes of the user's login process. The .cshrc file can contain variable definitions, aliases for commands, and other types of C shell commands. The file .login is executed only by the user's login shell process, not by subsequent C shell processes.
Sample .cshrc File
# This file is similar to the default .cshrc file on the
# Y-MP, which users are free to modify. This file is read
# upon every invocation of csh.
#
# Aliases
#
alias ls "/bin/ls -C"
alias lf "/bin/ls -CF"
alias dir 'echo " ";pwd;echo " ";lf;echo " " '
alias up "cd .."
alias ty cat
alias bye exit
#
# Default search path
#
set path=(. ~/bin /bin /usr/bin /usr/ucb /usr/local/bin)
#
# Define other variables
#
set history=24
setenv EDITOR /usr/bin/vi
#
# Set prompt to ymp%:
#
set prompt="`uname -n`% "
#
# Set default file permission to exclude other:rw and group:w
#
umask 026
Every user is provided with default .cshrc and .login files, but is free to modify them. Users should be careful about modifying the files, since unexpected things can occur if the wrong commands are inserted.
Under the C shell you can implement commands in .cshrc so that they affect your current environment with
% source .cshrc
close snip ...
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 02:54 AM
тАО06-08-2006 02:54 AM
Re: PS1 for C Shell
# set prompt="`whoami`@`hostname` $cwd ->"
It shows the current working directory only once when i execute it. When i traverse across, it remains the same.
Thanks,
Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 03:07 AM
тАО06-08-2006 03:07 AM
Re: PS1 for C Shell
adapted from another thread:
alias cd 'cd \!*;set prompt="`echo $LOGNAME`@$cwd >"'
Change the cd command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 03:13 AM
тАО06-08-2006 03:13 AM
Re: PS1 for C Shell
also
set prompt="$LOGNAME $PWD\>"
according to:
http://forums1.itrc.hp.com/service/forums/bizsupport/questionanswer.do?threadId=603965
"How to set PS1 in csh"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 03:31 AM
тАО06-08-2006 03:31 AM
Re: PS1 for C Shell
It is almost identical:
set prompt="`tput bold``uname -n``tput rmso` $PWD > "
Put the above command in .login or .cshrc
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 03:36 AM
тАО06-08-2006 03:36 AM
Re: PS1 for C Shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 03:57 AM
тАО06-08-2006 03:57 AM
Re: PS1 for C Shell
$PWD - stuff and more goodies - not for the prompt only - work very well in the compatible superset c-shell 'tcsh':
set prompt='%n@%B%m%b:%c '
would be good substitute for your PS1.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 04:28 AM
тАО06-08-2006 04:28 AM
Re: PS1 for C Shell
I found a lengthy method though,
setenv HOST `uname -n`
alias setprompt 'set prompt="$HOST $cwd # "'
alias cd 'cd \!* && setprompt'
alias pushd 'pushd \!* && setprompt'
alias popd 'popd \!* && setprompt'
setprompt
I am looking for a one-liner.
Thanks,
Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 04:39 AM
тАО06-08-2006 04:39 AM
Re: PS1 for C Shell
the setting of the prompt via
set prompt='%n@%B%m%b:%c '
in TCSH worked for me - perhaps use %M instead of %m.
Nevertheless
set prompt="%n@%B`uname -n`%b:%c >"
should work as well.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 03:44 PM
тАО06-08-2006 03:44 PM
Re: PS1 for C Shell
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 07:01 PM
тАО06-08-2006 07:01 PM
Re: PS1 for C Shell
I tried on my machine:
$ echo $0
-sh
$ csh
tpol 22: alias cd 'cd \!*;set prompt="`hostname` $cwd >"'
tpol 23: cd /tmp
tpol /tmp >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 08:14 PM
тАО06-08-2006 08:14 PM
Re: PS1 for C Shell
myhpux /tmp #csh
# alias cd 'cd \!*;set prompt="`hostname` $cwd >"'
#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 08:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 08:29 PM
тАО06-08-2006 08:29 PM
Re: PS1 for C Shell
# alias cd 'cd \!*;set prompt="`tput bold``hostname``tput rmso` $cwd >"'
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 08:30 PM
тАО06-08-2006 08:30 PM
Re: PS1 for C Shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 08:36 PM
тАО06-08-2006 08:36 PM
Re: PS1 for C Shell
ok, lets go back to the old CSH.
I suggest you put all prompt related stuff in a file ~/.prompt like I've done for a project of us (ignore Clearcase-Stuff).
~/.cshrc:
setenv HOST=`uname -n`
if ($?prompt && -f $HOME/.prompt) then
if ("$prompt" != "") source $HOME/.prompt
alias cd "cd \!*; source $HOME/.prompt"
endif
~/.prompt:
if ( $?prompt ) then
if ( $?CLEARCASE_ROOT ) then
if ($?tcsh) then
set icon=${CLEARCASE_ROOT:t}
else
set icon=`basename $CLEARCASE_ROOT`
endif
set ccview=${icon}:
else set ccview= icon=$HOST
endif
if ( ($TERM == xterm) || ($TERM == dtterm) ) then
# $cwd as a window title:
# echo -n "^[]2;${cwd}^G^[]1;${icon}^G"
echo -n "^[]2;${icon}^G^[]1;${icon}^G"
endif
if ($?tcsh) then
set prompt="${HOST}:${ccview}%~:! "
else
set prompt="${HOST}:${ccview}${cwd}:! "
endif
endif
mfG Peter