csh is root's shell?

John Baldwin jhb at FreeBSD.org
Thu Oct 7 11:37:16 PDT 2004


On Thursday 07 October 2004 12:44 pm, Don Lewis wrote:
> On  7 Oct, Nikolay Kalev wrote:
> > On Thu, 7 Oct 2004 08:25:04 -0300, Renato Botelho <rbgarga at gmail.com> 
wrote:
> >> On Thu, 7 Oct 2004 10:29:23 +0300, Nikolay Kalev <nkalev at gmail.com> 
wrote:
> >> > Ok here is the fix. I removed F1-F6 options, will research them this
> >> > weekend :-) Option CTRL+W is added, very neat thanks ! Please email me
> >> > for other suggestions.
> >>
> >> Other thing,
> >>
> >> You can replace this
> >>
> >> if ($LOGNAME == "root") then
> >>                 set prompt="[%B%m%b]:%S%/%s# "
> >>                 else
> >>                 set prompt="[%B%m%b]:%S%/%s> "
> >> endif
> >>
> >> with
> >>
> >> set prompt="[%B%m%b]:%S%/%s%# "
> >>
> >> %# will put # to root and > to others
> >
> > nice thank you :-). I will release soon another fix.
>
> This is what I use:
>
>         set prompt = '%m:%c4 %h%#'
>         if ($?TERM && $TERM == xterm) then
>                 set prompt='%{\033]0;%n@%m:%c5\007%}%m:%c %h%#'
>         endif
>
> It adds the last few components of $cwd and the history event number to
> the prompt.  When running in an xterm, it puts the username, hostname,
> and the last part of $cwd in the xterm title.

You can use the precmd alias for that.  Here's my .tcshrc.interactive file 
that I use for interactive sessions:

# extra tcsh configuration for interactive shells

setenv	PAGER	less
setenv	BLOCKSIZE	K
setenv	EDITOR	vi
if ($?DISPLAY) then
	if ( "$DISPLAY" == ":0.0" ) then
		setenv	EDITOR gnuclient
	endif
endif
setenv	CSCOPE_EDITOR $EDITOR

# An interactive shell -- set some stuff up
set pushdtohome
set complete=enhance
set autolist=ambiguous
set autoexpand
set autocorrect
set backslash_quote
set notify
set implicitcd
set correct=all
set rmstar

set prompt="\n[%B%P%b] (%l) %B%n@%m%b:%.03\n%# "
unset promptchars
set ellipsis
set history=200
set savehist=(200 merge)
set histlit
set histdup=erase
set histfile=~/.history_`hostname -s`

bindkey "^W" backward-delete-word
bindkey -k up history-search-backward
bindkey -k down history-search-forward

if (($term =~ xterm*) || ($term == eterm)) then
	alias precmd 'echo -n "]2;${USER}@${HOST}:$cwd"'
	# XXX - stupid tcsh processes this for subshells!
	#alias jobcmd 'echo -n "]2;${USER}@${HOST}:$cwd - \!#"'
	#cwdcmd
endif

if ( -x /usr/local/bin/p4 ) then
	setenv P4EDITOR $EDITOR
endif

# set completions
source ~/.completions

For completions I have this:

# tcsh completions

# shell builtins
complete limit	'c/-/(h)/' 'n/-/l/' 'p/1/l/'
complete {un,}alias 'p/*/a/'
complete {un,}complete 'p/*/X/'
complete unset	'p/*/s/'
complete unsetenv 'p/*/e/'
complete which	'p/*/c/'

# file operations
complete {cd,rmdir,pushd} 'p/1/d/' 'p/2-/x:Only one directory allowed./'
complete chgrp	'c/-/(f v h R)/' 'n/-/g/' 'p/1/g/' 'p/*/f/'
complete chown	'c/-/(f v h R)/' 'c/*:/g/' 'n/-/u/' 'p/1/u/' 'p/*/f/'
complete find	'n/-{,i}name/f/' 'n/-{,[acm]}newer/f/' 'n/-f/d/' \
		'n/-exec/c/' 'n/-ok/c/' 'n/-user/u/' 'n/-group/g/' \
		'n/-type/(b c d f l p s)/' \
		'c/-/(E H L P X d s x f amin anewer atime cmin cnewer ctime \
		delete depth empty exec execdir flags fstype group iname inum \
		ipath iregex links ls maxdepth mindepth mmin mnewer mtime name \
		newer nogroup nouser ok okdir path perm print print0 prune \
		regex size type user false not and or xdev)/' \
	        'p/*/d/'
complete ln	'c/-/(f h i n s v)/' 'p/*/f/'

# other utils
complete kill	'c/-/S/' 'p/*/`ps -x | grep -v PID | awk \{print\$1\}`/'
complete killall 'c/-/S/' 'p/*/c/'
complete umount 'c/-/(f v)/' 'C@/*@`mount -p | awk \{print\$2\}`@' 'p@*@(/)@@'
complete nroff	'c/-m/(doc an)/' 'p/*/f:*.[1-9]/'

# common 3rd party apps
complete acroread* 'p/*/f:*.pdf/'
set CVSCOMMANDS=(add admin annotate checkout commit diff edit editors export)
set CVSCOMMANDS=($CVSCOMMANDS history import init log login logout pserver)
set CVSCOMMANDS=($CVSCOMMANDS rannotate rdiff release remove rlog rtag server)
set CVSCOMMANDS=($CVSCOMMANDS status tag unedit update version watch watchers)
complete *cvs	'n/-T/d/' 'n/-e/c/' 'n/-d/d/' 'n/-H/$CVSCOMMANDS/' \
		'c/--/(help help-commands help-options help-synonyms)/' \
		'n/-r_disabled/(1.)//' 'c/-r/(1.)//' \
		'c/-/(a d e f g H l n Q q R r s T t u v w z -)/' \
		'p/1/$CVSCOMMANDS/'
complete dhclient 'n/-lf/f/' 'n/-pf/f/' 'n/-cf/f/' 'n/-sf/f/' \
		'c/-/(p D d q 1 r lf pf cf sf s g n nw w)/' 'p/*/`ifconfig -l`/'
complete {dvips,xdvi} 'p/*/f:*.dvi/'
complete gv	'p/*/f:*.ps/'
complete lynx	'p/*/f:*.htm[l]/'
complete mpg123 'n/-@/f:*.m3u/' 'p/*/f:*.mp3/'
if ( -x /usr/local/bin/p4 && $?P4CONFIG ) then
	set P4COMMANDS=`p4 help commands | grep -v Perforce | awk '{print $1}'`
	set P4HELPCOMMANDS=($P4COMMANDS simple commands environment \
		filetypes jobview revisions usage views)
	complete p4	'c/-/(a c b d du f i l o s t)/' \
		'n/-b/`p4 branches | awk \{print\$2\}`/' \
		'n/-l/`p4 labels | awk \{print\$2\}`/' \
		'c/\#/(head none)/' \
		'c/@/`p4 labels | awk \{print\$2\}`/' \
		'n/branch/`p4 branches | awk \{print\$2\}`/' \
		'N/branch/`p4 branches | awk \{print\$2\}`/' \
		'n/client/`p4 clients | awk \{print\$2\}`/' \
		'N/client/`p4 clients | awk \{print\$2\}`/' \
		'n/counter/`p4 counters | awk \{print\$1\}`/' \
		'n/help/$P4HELPCOMMANDS/' \
		'n/label/`p4 labels | awk \{print\$2\}`/' \
		'n/user/`p4 users | awk \{print\$1\}`/' \
		'p/1/$P4COMMANDS/'
endif
complete sudo	'p/1/c/'
complete xv	'p/*/f:*.{gif,jpg,jpeg,png,tiff,bmp,xpm,pnm}/'
complete figlet	'n#-f#F:/usr/local/share/figlet/# #'
complete cowsay	'n#-f#F:/usr/local/share/cows/# #'

# FreeBSD-specific
complete dd	'c/[io]f=/f/' \
		'c/conv=/(ascii block ebcdic lcase noerror notrunc osync \
		sparse swab sync ucase unblock)/,' \
		'C/*/(bs cbs count files ibs if obs of seek skip conv)/='
complete burncd	'c/-/(d e f F m n p q s t v)/' 'C#/dev/#f:*cd*#' \
		'n#-f#(/dev/)##' 'n/-s/x:speed/' 'n/data/f:*.iso/' \
		'n/format/(dvd+rw)/' \
		'p/*/(msinfo blank erase format fixate raw audio data mode1 mode2 XAmode1 
XAmode2 vcd dvdrw)/'
complete ifconfig 'c/-/(a d u m)/' 'n/-/`ifconfig -l`/' 'p/1/`ifconfig -l`/'
complete ipfw	'c/-/(a d e f q t N)/' \
		'n/add/(allow permit accept pass deny drop reject reset \
		count skipto num divert port tee port)/' \
		'p/*/(flush add delete list show zero)/'
complete kldunload 'c/-/(i v)/' \
		'n/-i/`kldstat | awk \{print\$1\} | egrep -v \(Id\|1\)`/' \
		'p/*/`kldstat | awk \{print\$5\} | egrep -v \(Name\|kernel\)`/'
if ( `uname -r` =~ 4.* ) then
	complete kldload 'C#*#F:/modules/# #'
else
	complete kldload 'p/*/f:*.ko/'
endif
complete pkg_{delete,info,version} 'C#*#D:/var/db/pkg/# #'
complete screen	'c/-/(d list r wipe x)/' \
		'n/-d/`screen -list | grep \'^	.*Attached\' | cut -f 2`/' \
		'n/-r/`screen -list | grep \'^	.*Detached\' | cut -f 2`/' \
		'n/-wipe/`screen -list | grep \'^	.*Dead\' | cut -f 2`/' \
		'n/-x/`screen -list | egrep \'^	.*(At|De)tached\' | cut -f 2`/'
complete sysctl 'p/*/`sysctl -aN`/'

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the freebsd-current mailing list