# Share your .tcshrc file



## rbelk (Jan 17, 2011)

I decieded to start this thread after reading the thread 'Which shell do you use?'.

I'll start, mine is below.


```
# .cshrc - csh resource script, read at beginning of execution by each shell
#
#

# -- Set up command aliases
alias searchports	'find /usr/ports -type f -name pkg-descr | xargs grep -i $1'
alias cdp	'echo $cdpath | tr -s : \\012'
alias checksym	'find -L . -type l'
alias cls	'clear'
alias cp	'cp -ip'
alias cx	'chmod ugo+x'
alias d		'tcsh $HOME/.login'
alias df	'df -h -t ufs,nfs'
alias exd	'export DISPLAY=":0"'
alias free	'freebsd-memory | tail -n5'
alias ft	'find . -maxdepth 1 -type f -mtime -1'
alias fta	'find . -type f -mtime -1'
alias grep	'grep --color="auto"'
alias h		'history'
alias h25	'history 25'
alias hist	'history|grep $1'
alias hs	'history | egrep'
alias j		'jobs -l'
alias key	'man -k'
alias la	'ls -a'
alias lf	'ls -FA'
alias ll	'ls -lA'
alias ls	'ls -LFGP'
alias lsa	'ls -ld .*'
alias lsc	'ls -sSh'
#alias lsd	'ls -ld *(-/DN)'
alias lsd	'ls -ld *'
alias lsnew	'ls -rtl *(.) | tail '
alias lt	'ls -t | head'
alias mc	'mc -ab'
alias mv	'mv -i'
alias na	'screen -t "\!:1" "\!:1"'
alias notes	'vim /home/rbelk/notes.txt'
alias ns	'screen -t "\!:1" ssh -o ServerAliveInterval=300 -o TCPKeepAlive=yes "\!:1"'
alias pi	'pkg_info'
alias pine	'alpine'
alias po	'popd'
alias pu	'pushd'
alias pwfh	'ps wfh'
alias g		'elinks http://www.google.com'
alias renew	'source ~/.tcshrc'
alias rlog	'rlog -zLT'
alias rm	'/usr/local/scripts/rm_alias.sh'
alias root	'sudo -i'
alias rr	'rehash ; renew'
alias rrm	'/bin/rm'
alias scppub	'scp $HOME/.ssh/id_dsa.pub "\!:1":~/.ssh/authorized_keys'
alias showpath	'echo $PATH | tr -s : \\012'
alias shred	'gshred'
alias sl	'screen -ls'
alias spin	'spinner -n'
alias spn	'portless -W'
alias srd	'screen -RD $USER'
alias t		'/usr/local/bin/todo -d $HOME/.todo.cfg'
alias tcfg	'vim ~/.tcshrc'
alias toupgrade	'pkg_version -o -I -L='
alias ttar	'tar -tvzf'
alias utar	'tar -xvzf'
alias vdiff	'vim -d'
alias vi	'vim'
alias viewlog	'screen -t viewlog sudo tail -F /var/log/all.log'
alias vnstat	'vnstat -i em0'
alias vvi	'/usr/bin/vi'
alias weather	'weather -a -z ms/USMS0175 -f'
alias webshare	'python -m SimpleHTTPServer 9914'
alias whatsmyip	'elinks -dump http://whatismyip.org/'
alias which-command	'whence'
alias xs	'screen -l -xR -S $USER'
alias yesterday	'date -v-1d +%d/%m/%Y'

[ -x /usr/local/bin/most ] && alias less	'most -w'
[ -x /usr/local/bin/most ] && alias more	'most -w'
[ -x /usr/local/bin/most ] && alias most	'most -w'

# -- A righteous umask
umask 22

# -- Set up search path
set path = (\
        /sbin \
        /bin \
        /usr/sbin \
        /usr/bin \
        /usr/games \
        /usr/local/sbin \
        /usr/local/bin \
        /usr/X11R6/bin \
        $HOME/bin \
        $HOME/mybin \
        /usr/local/scripts \
        /usr/local/uxscripts \
        )

# -- Set up CDPATH
set cdpath = (\
        . \
        ~/ \
        ~/folders \
        ~/projects \
        ~/work \
        )

# -- Set up global options
limit coredumpsize 0
setenv  LANG en_US.UTF-8
setenv  EDITOR  vim
setenv  PAGER   less
setenv  BLOCKSIZE       K
setenv  CLICOLOR
setenv  WWW_HOME "http://www.google.com/"
setenv	FTP_PASSIVE_MODE
setenv  LSCOLORS "ExGxFxdxCxegedabagExEx"
setenv  OS `uname`
setenv  GREP_COLOR '1;37;41'
setenv	HTTP_AUTH "'basic:*"

# -- An interactive shell -- set some stuff up
if ($?prompt) then
	set prompt="[%B%m: %/%b] `date +%a` %t <\!> $ "
	set colorcat
	set ignoreeof
	set autoexpand
	set autocorrect
	set correct=cmd
	set rmstar
	set filec
	set history = 1000
	set savehist = 1000
	set mail = (/var/mail/$USER)
	set noclobber
	set autolist
	set correct = cmd
	set nobeep
#	set watch = (0 any any)

	complete {,un}alias     'p/1/a/' 'p/2/c/'
	complete {c,push,pop}d  'C/*/d/'
	complete exec           'p/1/c/'
	complete man            'C/*/c/'
	complete {where,which}  'C/*/c/'
	complete {,un}set       'p/1/s/'
	complete {,un}setenv    'C/*/e/'
	complete printenv       'C/*/e/'
	complete bindkey        'p/1/b/'
	complete fg             'c/%/j/'
	complete kill           'c/%/j/' 'c/-/S/'
	complete chgrp          'p/1/g/'
	complete chown          'p/1/u/'
	complete limit          'C/*/l/'
	complete find           'p/1/d/' 'n/-user/u/' 'n/-group/g/'
	complete pkg_info	'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G W O x X e E l t V P)/' \
			'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%;s%^\(.*\)-[0-9].*%\1%"`@'
	complete pkg_delete	'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%"`@'
	complete portmaster	'n@*@`\ls -1 /var/db/pkg | sed "s%/var/db/pkg/%%;s%^\(.*\)-[0-9].*%\1%"`@'
	complete portsnap	'c/-/(I d f k p s)/' \
			'n/-d/d/' \
			'n/-p/d/' \
			'n/*/(fetch extract update)/'
	complete pkg_add 'n@-r@`awk -F\| \{sub\(/-\[0-9\]\.\*\/\,\"\"\,\$1\)\;print\ \$1\} /usr/ports/INDEX | sort -u`@'
endif
```

Please share yours. Moderators, if you think this is in the wrong forum please move.


----------



## SirDice (Jan 17, 2011)

Mine's fairly standard:

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

if ( -x /usr/local/bin/vim ) then
        alias vi        vim
endif

# 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   less
setenv  BLOCKSIZE       K
setenv  LC_ALL en_US.ISO8859-1

setenv  CLICOLOR

switch($TERM)
        case "xterm*":
                setenv TITLE "%{\033]0;%n@%m:%~\007%}"
                breaksw
        default:
                setenv TITLE ""
                breaksw
endsw

if ($?prompt) then
        # An interactive shell -- set some stuff up
        set filec
        set history = 100
        set savehist = 100
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
                set prompt = "${TITLE}%n@%m:%~%#"
        endif
endif
```


----------



## wblock@ (Jan 17, 2011)

Nothing big except for all the completion settings I just shamelessly copied from rbelk.

A few shortcuts for tracking down spam senders.

```
alias afri      whois -h whois.afrinic.net
alias arin      whois -h whois.arin.net
alias apnic     whois -h whois.apnic.net
alias ripe      whois -h whois.ripe.net
alias lacnic    whois -h whois.lacnic.net
alias jpnic     'whois -h whois.nic.ad.jp \!*/e'
```

Also this, so the console autorepeat isn't slower than a turtle in molasses.

```
switch ($tty)
  case "ttyv*":
    alias precmd /usr/sbin/kbdcontrol -r fast
endsw
```

And of course Home and Delete:

```
bindkey "\e[3~" delete-char
bindkey "\e[1~" beginning-of-line
```


----------



## Carpetsmoker (Jan 17, 2011)

http://code.arp242.net/config/src/tip/home/dot.tcsh/?at=default

It should work on FreeBSD, OpenBSD, OpenSolaris, and Linux.
It should in general be fairly portable (e.g. It checks if "vim" actually exists before setting $EDITOR to vim, etc.).

It's a bit of a mess and has "grown" over the last few years. I also have a couple of different flavours on different machines floating around 


Edit 20141029: Update link


----------



## devinteske (Mar 9, 2011)

*Work in progress*

I'd like to join the thread and think I have a fair bit to contribute. I'm sure there's some fun toys in here that you might be interested in (especially the randomizations).

My ~/.tcshrc file:

```
# -*- tab-width:  4 -*- ;; Emacs
# vi: set tabstop=4     :: Vi/ViM
#
# .tcshrc
#   Author:      Devin Teske <dteske@vicor.com>
#   Last Change: 2011 Mar 2
############################################################ GLOBALS

#
# Global exit status variables
#
setenv SUCCESS 0
setenv FAILURE 1

#
# Are we running interactively?
#
setenv interactive 0
if ( $?prompt ) then
    setenv interactive 1
endif

############################################################ ALIASES

#
# Alias to set the title of your ANSI-compatible shell window.
#
alias settitle printf '"\033]2;\!*\a\033]1;\!*\a\033]0;\!*\a"'

#
# Random keepalive [ka] alias (based on system-availability of various
# fun utilities).
#
alias RANDOM 'printf "%u\n" 0x`xxd</dev/urandom|head -1|cut -b 10-13`'
alias have 'which \!^ >& /dev/null'
@ n = 0
have worms   && eval set ka$n='"worms -d 25"' && @ n++
have rain    && eval set ka$n='"rain -d 50"' && @ n++
have grdc    && eval set ka$n='"grdc"' && @ n++
have fortune
if ( $? == 0 ) then
    set fort='sh -c "while :;do fortune;sleep 80;echo --;done"'
    eval set ka$n="'$fort'"
    @ n++
endif
if ( $n <= 0 ) then
    set ka0="sh -c 'while :;do echo -n .;sleep 80;done'"
    @ n++
endif
alias ka '@ x = `RANDOM` / ( 65537 / '$n' ); eval eval \$ka$x'
unset n

#
# Alias to use in-place of grep(1) whenever you want to preserve the first line
# of output (often the header when viewing output from ps(1), lsof(8), df(1),
# netstat(8), arp(8), lsmod(8), route(8), free(1), and many many others).
#
alias hgrep awk '"BEGIN { getline; print } /\!^/ { print }"' \!:2\*

#
# Alias for becoming root while maintaining shell customizations.
#
alias srsu sr env tcsh

############################################################ SHELL BEHAVIOR

#
# Set prompt style
#
set prompt='%{\033[32;1m%}%n@%m %{\033[34;1m%}%c %#%{\033[0m%} '

#
# Set the window title for terminals such as "xterm", "rxvt", and others
#
if ( $interactive ) then
    settitle $USER@$HOST $HOME
endif

#
# Make new files group-writable by default
#
umask 002

############################################################ MISCELLANEOUS

#
# cvs(1) settings
#
setenv CVS_RSH cvs_rsh
setenv CVSROOT cvs:/repos/projects

#
# *beep**beep**beep**beep**beep*X(1) settings
#
setenv IRCNICK devinteske
setenv IRCSERVER frenode.net
setenv IRCNAME dteske

#
# sysrc(8) settings
#
setenv SYSRC_VERBOSE 1

#
# Override the default password prompt for sudo(8). This helps differentiate
# the sudo(8) password prompt from others such as su(1), ssh(1), and login(1).
#
setenv SUDO_PROMPT '[sudo] Password:'
```

NOTE: My .bash_profile is over 6-times larger (note: I may be a bash user, but I certainly do not hate on [t]csh).


----------



## wblock@ (Oct 4, 2011)

Just wanted to add some autocompletions that have been useful to me:

service(8) autocompletes from system and installed port services.

```
complete service        'n@*@`ls /etc/rc.d /usr/local/etc/rc.d | sed -e "/:/d"`@'
```

pkill(1) autocompletes from the list of running processes.

```
complete pkill          'n@*@`ps -a -x -c -o command="" | sort | uniq`@'
```

Revised autocomplete definitions for ports and packages.

```
complete pkg_delete     'c/-/(i v D n p d f G x X r)/' \
                        'n@*@`ls /var/db/pkg`@'
complete portmaster     'c/-/(C G H K B b g n t v w f i D d m x P PP)/' \
                        'n@*@`ls /var/db/pkg`@'
complete portupgrade    'c/-/(A b B c C D e f F i k l L m M n N o O p P PP q r R s S u v w W x y)/' \
                        'n@*@`ls /var/db/pkg`@'
```


----------



## SirDice (Oct 4, 2011)

That reminds me, I need to look at that too. I'd like to auto-complete zfs filesystems.


----------



## wblock@ (Oct 4, 2011)

If you can figure out a way to get make(1) to show a list of all possible targets, that's one I want to do also.


----------



## dalecosp (Oct 4, 2011)

*Some "funnies" in this one*

Kind of interesting how your .cshrc shows some history about you after several years.

Nothing really "uber-leet" here; I find the DOS substitutions kinda funny in retrospect, though :e


```
# $FreeBSD: src/share/skel/dot.cshrc,v 1.13 2001/01/10 17:35:28 archie Exp $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
#
alias h		history 25
alias j		jobs -l
alias ls	ls -FG
alias la	ls -a
alias lf	ls -FA
alias ll	ls -lAFG
alias mail      mutt
alias nomail    "kill -HUP `pgrep thunderbird`"
alias lockp	"cls && lock -p -t 15000"
alias rootmail	"sudo mutt -f /var/mail/root"
alias pt	"pgrep thunderbird"
alias tb	"thunderbird &"
alias pico      nano
alias snoop	"sudo tcpdump -i xl0 | grep -v ssh | grep -v myserver"
alias py	"ping -t 6 yahoo.com"
alias dir       ls
alias rm        rm -i
alias mv	mv -i
alias cp	cp -i
alias me	whoami
alias a:	"sudo mount_msdosfs /dev/fd0 /floppy && cd /floppy && ls -l"
alias noa:	"cd && sudo umount /floppy"
alias tm	/usr/local/textmaker5/textmaker/tm
alias mp	mousepad
alias up	ping -t2 yahoo.com
alias dial	sudo ppp -nat -background tdon
alias undial    "pgrep ppp | xargs sudo kill"
alias cls	clear
alias clss	"clear && ls"
alias d:	sudo mount_cd9660 /dev/acd0 /cdrom
alias checkflow sudo tcpdump -i tun0
alias localflow sudo tcpdump -i vr0
#alias cat	/usr/local/bin/php -q /home/kadmin/scripts/cat
alias refetch   /usr/local/bin/sudo /usr/local/bin/php -q /home/kadmin/scripts/refetch
alias amavisd   sudo su vscan -c /usr/local/sbin/amavisd
alias mm	"cd && cls"
alias fdformat  sudo /usr/sbin/fdformat -f 1440 /dev/fd0
alias squidk	"pgrep squid | xargs sudo kill -HUP"
alias spell	/home/kadmin/scripts/spell
alias netoff    "sudo ipfw add 00001 deny ip from any to any via xl0"
alias neton     "sudo ipfw delete 00001"
alias zeke     "Eterm -T Yolanda -e ssh yolanda &" 
alias lisha     "Eterm -T Kermit -e ssh kermit &"
alias killmonkey "/bin/pgrep seamonkey | /usr/bin/xargs /bin/kill -s QUIT"
alias deadmonkey "/bin/pgrep seamonkey | /usr/bin/xargs /bin/kill -s QUIT"
alias dors "sudo /home/kadmin/scripts/unban runescape; sudo ipfw add 653 allow ip from foobar to any"
alias nors "sudo reban runescape; sudo ipfw delete 653"
alias unbanned "/usr/bin/grep # /etc/banned.list"
alias moz "cd /usr/local/lib/mozilla-gtk2/ && sh run-mozilla.sh &"
alias mailconnect "sudo ssh -L localhost:24:yolanda:52525 yolanda"
alias spammv "scp ~/spammers kadmin@yolanda:/home/kadmin/"

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin $HOME/bin $HOME/scripts /usr/local/libexec/nut)

#set watch = (0 any any)

setenv  CVS_RSH ssh
setenv	EDITOR	nano
setenv	PAGER	more
setenv	BLOCKSIZE	M
setenv  EMAIL  "me@mydomain.com"
setenv  CLICOLOR
setenv	TERM xterm-color
limit coredumpsize 0
set correct=cmd
#set prompt = "\n<%B$user%b@%B%m%b> [%/] [%B%T%b] \n% "

if ($?prompt) then
	# An interactive shell -- set some stuff up
	set prompt="\n%B%{\033[34m%}[%h] %d %D.%w.%Y %P\n%{\033[31m%}[%n@%m][%~]\n%{\033[30m%}%b"
	set filec
	set history = 5
	set savehist = 5
	set mail = (/var/mail/$USER)
	if ( $?tcsh ) then
		bindkey "^W" backward-delete-word
		bindkey -k up history-search-backward
		bindkey -k down history-search-forward
	endif
endif

cd ~
alias service network restart     echo 'Are you sure, or did you mean /etc/rc.d/netif restart?' 
alias 'service network restart'     echo 'Are you sure, or did you mean /etc/rc.d/netif restart?' 
alias freecell "wine /usr/home/kadmin/.wine/drive_c/windows/system32/freecell.exe"
```


----------



## wblock@ (Oct 4, 2011)

A better pkill(1) completion:

```
complete pkill          'c/-/(1 2 3 6 9 14 15 HUP INT QUIT ABRT KILL ALRM TERM)/'\
                        'n@*@`ps -a -x -c -o command="" | sort | uniq`@'
```

Incidentally, the tcsh(1) section on completion is totally undecipherable to me.  The above is because of some hints from this.  Still not sure what n@*@ does, but if understanding was required before use, I wouldn't be here.


----------



## Carpetsmoker (Oct 4, 2011)

> service(8) autocompletes from system and installed port services.
> 
> ```
> complete service        'n@*@`ls /etc/rc.d /usr/local/etc/rc.d | sed -e "/:/d"`@'
> ```



I use this for completing service(8):

```
complete service 'n/*/`service -l`/'
```

Seems a bit simpler to me 

I also have this for adding signals, it seems more complete than your version, doesn't add process names or PID's though:

```
complete kill 'c/-/S/' 'p/1/(-)//'
complete pkill 'c/-/S/' 'p/1/(-)//'
```



> If you can figure out a way to get make(1) to show a list of all possible targets, that's one I want to do also.



Not a bad idea, I only tested this quickly. Seatbelt not included 

The command to get a list of targets is:

```
make -pn | egrep '^[^#].*: $' | sed 's|: $||; s|\w||g'
```

Unfortunately, using this directly in a complete command is problematic ... AFAIK tcsh doesn't provide an easy way to escape the dollar sign ...  tcsh has some stupid limitations.

I put it in ~/bin/compmake and used this in my ~/.cshrc

```
complete make 'n/*/`compmake`/'
```

Seem to work for at least ports and /usr/src ...



			
				wblock@ said:
			
		

> A better pkill(1) completion:
> 
> ```
> complete pkill          'c/-/(1 2 3 6 9 14 15 HUP INT QUIT ABRT KILL ALRM TERM)/'\
> ...



The @'s are just a different delimiter, just as you can use a whole bunch of delimiters with most regexp implementations.
It's confusing to use an @ here because this is also a built-in and because it's far from a "conventional" delimiter like slash, comma, or pipe.
I'm not sure if all character are allowed like in regexps, IIRC @ is the only one mentioned explicitly in the manual

As a certain wizard would say, "one does not simply read tcsh(1)"
(t)csh is one of the more archaic pieces of "old" UNIX/BSD legacy. I use it because I've been using it so long I can do most of the stuff blind folded, but the more I learn about it, the more it's obvious it's really not very good (See: dollar-sign escape nonsense above). If you're new, I really wouldn't recommend it...


----------



## Carpetsmoker (Oct 4, 2011)

Here's a (better?) version which also skips all targets starting with a dot, typically not something you'd want to run as a user.


```
make -pn | egrep '^[^#.].*: $' | sed 's|: $||; s|\w||g'
```


----------



## wblock@ (Oct 5, 2011)

```
complete make           'n@*@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; s/[[:blank:]]*:.*//gp;"`@'
```
And now my brain hurts.


----------



## rbelk (Oct 5, 2011)

wblock@ said:
			
		

> ```
> complete make           'n@*@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; s/[[:blank:]]*:.*//gp;"`@'
> ```
> And now my brain hurts.



That has to be the best CSH alias I've seen in this thread, thanks wblock. I'll have to study this tomorrow. I'd stay up all night trying to figure the alias out! I started this thread to learn more about CSH and it's differences from the bourne shell and I've learned a lot!


----------



## Carpetsmoker (Oct 5, 2011)

Nice one wblock.


----------



## hedgehog (Oct 5, 2011)

It's awesome, wblock.

I haven't made much changes to .cshrc.
prompt:

```
set promptchars='$#'
set prompt="%{^[[01;34;1m%}[%T] %n@%m [%~] %#%{^[[00;39m%} "
```
It's looking like that (i have dark background): [14] user@host [~/tmp] $ 

and some keybindings:

```
bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
                bindkey "\e[1~" beginning-of-line  # Home
                bindkey "\e[3~" delete-char        # Delete
                bindkey "\e[4~" end-of-line        # End
```


----------



## johnd (Oct 5, 2011)

wblock@ said:
			
		

> A better pkill(1) completion:
> 
> ```
> complete pkill          'c/-/(1 2 3 6 9 14 15 HUP INT QUIT ABRT KILL ALRM TERM)/'\
> ...



tcsh(1) can complete signals too. So, a simpler form could look like this:


```
complete pkill          'c/-/S/'\
                        'n@*@`ps -a -x -c -o command="" | sort | uniq`@'
```


----------



## wblock@ (Oct 5, 2011)

Interesting.  It's possible to do multiple completions for the same parameter:

```
complete pkill 'c/-[A-Z]/S/' 'c/-[0-9]/(1 2 3 6 9 14 15)/' 'n@*@`ps -axc -o command="" | sort | uniq`@'
```

[A-Z] and [0-9] are glob patterns, not regexes.

I suspect @ is used just to avoid conflict with other common delimiters.


----------



## SirDice (Oct 6, 2011)

SirDice said:
			
		

> That reminds me, I need to look at that too. I'd like to auto-complete zfs filesystems.



Found this: http://www.mail-archive.com/zfs-discuss@opensolaris.org/msg08803/zfs_tcsh_completion


----------



## joel@ (Dec 28, 2011)

Currently something like this:

```
# Path
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin $HOME/bin)

if ($uid == 0) then
	set user = root
endif

set prompt = "%n@%m [%~] "

# Environment
setenv PAGER more
setenv LC_CTYPE sv_SE.UTF-8

# Enable colorized output
set color

# BSD ls colors
setenv LSCOLORS "Dxfxcxdxbxegedabagacad"

# Linux ls colors (but tcsh also wants it for autocompletion colors)
setenv LS_COLORS "di=01;33:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43:"

# Automatic filename completion
set filec

# List autocomplete possibilies
set autolist

# No beeping
set nobeep

# History
set history = 1000
set savehist = 1000

# Better ls
alias ls ls -ahoGF

# Set vim as default editor if it exists
if ( -x /usr/local/bin/vim ) then
	# FreeBSD default vim location
	setenv EDITOR /usr/local/bin/vim
	alias vi vim
else if ( -x /usr/bin/vim ) then
	# Mac OS X default vim location
	setenv EDITOR /usr/bin/vim
	alias vi vim
endif

# Manual pages with color
setenv LESS_TERMCAP_mb `echotc md; echotc AF 1`
setenv LESS_TERMCAP_md `echotc md; echotc AF 1`
setenv LESS_TERMCAP_me `echotc me`
setenv LESS_TERMCAP_se `echotc me`
setenv LESS_TERMCAP_so `echotc md; echotc AF 3; echotc AB 4`
setenv LESS_TERMCAP_ue `echotc me`
setenv LESS_TERMCAP_us `echotc md; echotc AF 4`
```
Latest version is always available from https://github.com/joeldahl/dotfiles/blob/master/.tcshrc


----------



## Carpetsmoker (Dec 28, 2011)

```
if ( -x /usr/local/bin/vim ) then
	# FreeBSD default vim location
	setenv EDITOR /usr/local/bin/vim
	alias vi vim
else if ( -x /usr/bin/vim ) then
	# Mac OS X default vim location
	setenv EDITOR /usr/bin/vim
	alias vi vim
endif
```

You can use *-X* (Capital X)


```
X   Executable in the path or shell builtin, e.g., `-X ls' and  `-X
               ls-F' are generally true, but `-X /bin/ls' is not (+)
```

i.e.

```
if (-X vim) then
	setenv EDITOR vim
	alias vi "vim"
else if (-X vi) then
	setenv EDITOR vi
endif
```


----------



## randomcop (Apr 24, 2012)

wblock@ said:
			
		

> Just wanted to add some autocompletions that have been useful to me:
> 
> 
> Revised autocomplete definitions for ports and packages.
> ...




Hi.

Thanks for the inspiration for the portupgrade autocompletion!

Here is my version that, when autocompleting, only shows old ports for which a newer port version is available. (you need an up to date INDEX file in your portstree for this to work)


```
complete portupgrade    'c/-/(A b B c C D e f F i k l L m M n N o O p P PP q r R s S u v w W x y)/' \
                        'n@*@`/usr/sbin/pkg_version -vq --index-only -L= | cut -d " " -f1`@'
```


----------



## Deleted member 48958 (Oct 23, 2016)

Here is few lines from my ~/.tcshrc

My custom prompt
`set prompt = " %{\033[1;37m%}%T %{\033[1;32m%}%C%{\033[1;37m%} %#%{\033[0m%} "`






same, but without bold fonts:
`set prompt = " %T %{\033[0;32m%}%C%{\033[0m%} %# "`

All prompt colors:





```
%{\033[0;31m%} — red
%{\033[1;31m%} — bold red
%{\033[0;32m%} — green
%{\033[1;32m%} — bold green
%{\033[0;33m%} — yellow
%{\033[1;33m%} — bold yello…
etc.
```
Color codes with 40 — %{\033[0;*4**m%}  should change font background, for example:





*Note:*
You always need to put the *%{\033[0m%}* at the end of your prompt, to reset colors to default.

For underlined text, use "%{\033[*4;3**m%}", for example
`set prompt = "[%P] %{\033[1;32m%}%n%{\033[1;37m%}@%m [B]%{\033[4;34m%}[/B]%/%{\033[0m%} (%l) \n%# "`

Some tcsh codes:


			
				`man tcsh` said:
			
		

> %/   The current working directory
> %~   The current working directory, but with one's home directory represented by `~'
> %c   The trailing component of the current working directory
> %C   Like %c, but without `~' substitution
> ...




Nice alias for ports usage 
	
	



```
alias p       'cd /usr/ports && cd'
```






Some more "alias"-es:

```
alias c         'cat'
alias q         'exit'
alias h         'history 25'
alias f         'psearch'
alias F         'find . -type f'
alias grep      'grep --color'
alias gnugrep   '/usr/local/bin/grep --color'
alias g         'grep -i'
alias v         'vim'
alias .         'pwd'
alias ...       '../..'
alias ls        'ls -SF'
alias la        'ls -a'
alias ll        '\ls -Flht'
alias mkdir     'mkdir -p'
alias s         'sudo'
alias ss        'sudo su -'
alias S         'source ~/.tcshrc'
alias H         'vim ~/.csh_history'
alias stat      'stat -x'
alias date      'date +"%d-%m-%Y, %H:%M"'
alias tkill     'tmux kill-session -t'
alias aw        'ansiweather'
alias cputemp   'sysctl -a | grep "dev.cpu.*.temperature"'
```
 (also try shells/tcshrc)


Also tcsh got built in autocorrect function, add "set correct = cmd" to ~/.tcshrc for example.
Some other features that I use:

```
if ($?prompt) then
        set prompt = " %T %{\033[0;32m%}%C%{\033[0m%} %# "
        set promptchars = "%#"
        set history = 5000
        set savehist = (5000 merge)
        set histfile = "$HOME/.csh_history"
        set histdup = erase              # save only unique history events
        set notify                       # notification when jobs change state
        #set recexact                    # completion always completes on a first exact match
        set autocorrect                  # spell-word editor command is invoked automatically
        set autoexpand                   # run expand-history before each completion attempt
        set implicitcd                   # change directory without cd
        set correct = cmd                # commands are automatically spelling-corrected
        set symlinks = chase             # symbolic link is expanded to the real name of the directory
        set complete = enhance           # completion ignores case and considers hyphens and underscores
        set autolist = ambiguous         # choices are listed only when completion fails
        set matchbeep = ambiguous        # beeps only when there is no match
        set color = ls-F                 # enables colors for the builtin autolist (TAB)
        set padhour                      # enable the printing of padding '0' for hours
        set noding                       # disable "Ding!" in the prompt time
        set rmstar                       # user is prompted before `rm *' is executed
        if ( $?tcsh ) then
                bindkey '\e[3~' delete-char              # delete
                bindkey '\e[1;5D' backward-word          # ctrl+left
                bindkey '\e[1;5C' forward-word           # ctrl+right
                bindkey '\e[3;3~' delete-word            # alt+delete
                bindkey '\e[1;3C' delete-word            # alt+right
                bindkey '\e[1;3D' backward-delete-word   # alt+left
                bindkey "\e[1~" beginning-of-line        # home
                bindkey "\e[4~" end-of-line              # end
                # rxvt key bindings
                bindkey '\eOd' backward-word             # ctrl+left
                bindkey '\eOc' forward-word              # ctrl+right
                bindkey '\e^[[3~' delete-word            # alt+delete
                bindkey '\e^[[C' delete-word             # alt+right
                bindkey '\e^[[D' backward-delete-word    # alt+left
                bindkey "\e[7~" beginning-of-line        # home
                bindkey "\e[8~" end-of-line              # end
        endif
endif

setenv          EDITOR          'vim'
setenv          PAGER           'less'
setenv          LESS            '-XAirs'
setenv          GREP_COLOR      '1;31'
setenv          CLICOLOR        '1'
setenv          LSCOLORS        'cxfxdxbxexeafaachcagbg'
```


If you do not want to type manually  "rehash" after each package installation,
add 
	
	



```
set autorehash = always
```
 to .tcshrc, and the list of available commands will be rebuilt for
each command completion or spelling correction attempt.

To auto start sysutils/tmux terminal multiplexer with /bin/tcsh shell, I'm using  
	
	



```
if (! $?TMUX) tmux -l -2
```
 in ~/.tcshrc.

…

And "just for lulz",
alias for thefuck (app which corrects previous console command).

```
alias fuck   'set fucked_cmd=`history -h 2 | head -n 1` && eval `thefuck ${fucked_cmd}`'
alias F       'fuck'
```
To install thefuck, install devel/py-pip, devel/py-colorama, devel/py-decorator, devel/py-pathlib2 and sysutils/py-psutil, then execute
`% pip install --user thefuck`


----------



## r0g3r (Nov 15, 2016)

```
# Change only root's prompt
if (`id -g` == 0) then
   set prompt="root@%m# "
endif

# This maps the "Delete" key to do the right thing
# Pressing CTRL-v followed by the key of interest will print the shell's
# mapping for the key
bindkey "^[[3~" delete-char-or-list-or-eof

# Make the Ins key work
bindkey "\e[2~" overwrite-mode

# Some common completions
complete cd       'p/1/d/'
complete chown          'p/1/u/'
complete dd       'c/[io]f=/f/ n/*/"(if of ibs obs bs skip seek count)"/='
complete find    'n/-fstype/"(nfs 4.2)"/' 'n/-name/f/' \
               'n/-type/(c b d f p l s)/' \
             'n/-user/u/ n/-group/g/' \
             'n/-exec/c/' 'n/-ok/c/' \
             'n/-cpio/f/' \
             'n/-ncpio/f/' \
             'n/-newer/f/' \
               'c/-/(fstype name perm prune type user nouser group nogroup size inum atime mtime ctime exec \
               ok print ls cpio ncpio newer xdev depth daystart follow maxdepth mindepth noleaf version \
               anewer cnewer amin cmin mmin true false uid gid ilname iname ipath iregex links lname empty path \
               regex used xtype fprint fprint0 fprintf print0 printf not a and o or)/' \
             'n/*/d/'
complete fg       'c/%/j/'
complete gpart   'p/1/(add backup bootcode commit create delete destroy modify recover resize restore set show undo unset)/' \
           'n/add/x:-t type [-a alignment] [-b start] [-s size] [-i index] [-l label] -f flags geom/' \
             'n/backup/x:geom/' \
             'n/bootcode/x:[-b bootcode] [-p partcode -i index] [-f flags] geom/' \
             'n/commit/x:geom/' \
             'n/create/x:-s scheme [-n entries] [-f flags] provider/' \
             'n/delete/x:-i index [-f flags] geom/' \
             'n/destroy/x:[-F] [-f flags] geom/' \
             'n/modify/x:-i index [-l label] [-t type] [-f flags] geom/' \
             'n/recover/x:[-f flags] geom/' \
             'n/resize/x:-i index [-a alignment] [-s size] [-f flags] geom/' \
             'n/restore/x:[-lF] [-f flags] provider [...]/' \
             'n/set/x:-a attrib -i index [-f flags] geom/' \
             'n/show/x:[-l | -r] [-p] [geom ...]/' \
             'n/undo/x:geom/' \
             'n/unset/x:-a attrib -i index [-f flags] geom/'
complete grep       'c/-*A/x:<#_lines_after>/' \
             'c/-*B/x:<#_lines_before>/' \
             'c/--/(extended-regexp fixed-regexp basic-regexp regexp file ignore-case word-regexp line-regexp \
               no-messages revert-match version help byte-offset line-number with-filename no-filename quiet silent \
               text directories recursive files-without-match files-with-matches count before-context after-context \
               context binary unix-byte-offsets)/' \
             'c/-/(A a B b C c d E e F f G H h i L l n q r s U u V v w x)/' \
             'p/1/x:<limited_regular_expression>/ N/-*e/f/' \
             'n/-*e/x:<limited_regular_expression>/' \
             'n/-*f/f/' \
             'n/*/f/'
complete ifconfig   'p@1@`ifconfig -l`@' \
             'n/*/(range phase link netmask mtu vlandev vlan metric mediaopt down delete broadcast arp debug)/' \
             'c/%/j/' \
             'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/'
complete kill       'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/'
complete killall   'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/'
complete kldload   'n@*@`ls -1 /boot/modules/ /boot/kernel/ | awk -F/ \$NF\ \~\ \".ko\"\ \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\}`@'
complete kldunload   'n@*@`kldstat | awk \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\} | grep -v Name`@'
complete make       'p@1@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; s/[[:blank:]]*:.*//gp;"`@' \
                 'n@-V@`make -ndv | & grep Global: | sed -E -e "s/^Global://" -e "s/ .*//" -e "/^[[:lower:]]/d" | sort | uniq`@'
complete man       'C/*/c/'
complete netstat   'n@-I@`ifconfig -l`@'
complete pkg_delete     'c/-/(i v D n p d f G x X r)/' 'n@*@`ls /var/db/pkg`@'
complete pkg_info       'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G O x X e E l t V P)/' 'n@*@`\ls -1 /var/db/pkg | sed s%/var/db/pkg/%%`@'
complete ping       'p/1/$hosts/'
complete pkill       'c/-/S/' \
                 'n@*@`ps -axc -o command="" | sort | uniq`@'
complete portmaster   'c/--/(always-fetch check-depends check-port-dbdir clean-distfiles clean-packages delete-build-only \
               delete-packages force-config help index index-first index-only list-origins local-packagedir \
               no-confirm no-index-fetch no-term-title packages packages-build packages-if-newer packages-local \
               packages-only show-work update-if-newer version)/' \
             'c/-/(a b B C d D e f F g G h H i l L m n o p r R s t u v w x)/' \
             'n@*@`pkg_info -E \*`@'
complete rsync   "c,*:/,F:/," \
             "c,*:,F:$HOME," \
             'c/*@/$hosts/:/'
complete scp   "c,*:/,F:/," \
             "c,*:,F:$HOME," \
             'c/*@/$hosts/:/'
complete service      'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/'
complete svn       'C@file:///@`'"${HOME}/etc/tcsh/complete.d/svn"'`@@' \
             'n@ls@(file:/// svn+ssh:// svn://)@@' \
             'n@help@(add blame cat checkout cleanup commit copy delete export help import info list ls lock log merge mkdir move propdel \
               propedit propget proplist propset resolved revert status switch unlock update)@' 'p@1@(add blame cat checkout cleanup commit \
               copy delete export help import info list ls lock log merge mkdir move propdel propedit propget proplist propset resolved \
               revert status switch unlock update)@'
complete ssh   'p/1/$hosts/' \
             'c/-/(l n)/' \
             'n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/'
complete sysctl 'n/*/`sysctl -Na`/'
complete tmux   'n/*/(attach detach has kill-server kill-session lsc lscm ls lockc locks new refresh rename showmsgs source start suspendc switchc)/'
complete which   'C/*/c/'

if ( -f /etc/printcap ) then
  set printers=(`sed -n -e "/^[^    #].*:/s/:.*//p" /etc/printcap`)
  complete lpr   'c/-P/$printers/'
  complete lpq   'c/-P/$printers/'
  complete lprm   'c/-P/$printers/'
endif

set prompt="%{\e[2;37m[%P] %{\e[0;33m%}%n%{\e[0m%}@%{\e[34m%}%m %{\e[32m%}%~%{\e[31m%} "\$"%{\e[0m%} "

# Color ls
alias ll   ls -l
alias ls   ls -G
alias la   ls -a
alias ..   cd ..
alias dload   youtube-dl -x --audio-format mp3 --audio-quality 320K

# Color on many system utilities
setenv CLICOLOR 1

# other autolist options
set       autolist = TAB
```


----------



## Deleted member 48958 (Apr 27, 2017)

By the way… new *tcsh* version was released,
	
	



```
% tcsh --version
tcsh 6.20.00 (Astron) 2016-11-24 (x86_64-amd-FreeBSD) options wide,nls,dl,al,kan,sm,rh,color,filec
```
It is available now on FreeBSD 11.0-STABLE, on FreeBSD 12.0-CURRENT and on FreeBSD 10.3-STABLE.

FreeBSD 10.3-RELEASE and FreeBSD 11.0-RELEASE still uses 
	
	



```
tcsh 6.18.01 (Astron) 2012-02-14 (i386-intel-FreeBSD) options wide,nls,dl,al,kan,sm,rh,color,filec
```
If you want to use tcsh 6.20.00 on FreeBSD 10.3-RELEASE or FreeBSD 11.0-RELEASE,
you can install it to /usr/local:

```
% wget ftp://ftp.astron.com/pub/tcsh/tcsh-6.20.00.tar.gz
% tar xvf tcsh-6.20.00.tar.gz
% cd tcsh-6.20.00/
% ./configure
% make
% sudo make install
% sudo mv /bin/tcsh /bin/tcsh.bak
% sudo ln -s /usr/local/bin/tcsh /bin/tcsh
```
Just switch to original /bin/tcsh when you'll do a `freebsd-update`. Also use /bin/csh like a root shell.

I really hope that thay fixed tcsh history, finally… "csh shell history is puzzled", because of this problem I've even switched to zsh.
But it seems that new version doesn't have this problem anymore.

But I'm really missing one feature,
I want to be able to save my tcsh history after each tcsh command.
"alias precmd    'history -L; history -S'" saves, but it also adds some strange history events





*UPD: *Solved. It seems

```
if ($?prompt3) then
    alias postcmd    'history -S'     # update and save history after each command
endif
```
 do the job, without any issues. When shell is interactive, it'll save history after each command,
also history between different tcsh sessions will be shared, because it also updates current session history list.
It should be added to the bottom of ~/.tcshrc, because histfile should be set before.

Also I cannot find anything about tcsh builtin `history` command and about its flags




TC Shell power users, where can I read about it? `man history` is not helpful at all, because it opens this manual page,
also I cannot find anything about `history`  flags (-chrSLMT) on tcsh manual page:




Or may be it is a bug and I should create a bug report?


----------



## Deleted member 48958 (Apr 29, 2017)

ILUXA said:


> `history` flags (*-chrSLMT*)


Found it  here


----------



## Deleted member 48958 (Apr 29, 2017)

Also found few very usable ~/.tcshrc options, that are not described in this theme yet. 
To notify you when someone logs in or out,




add

```
set watch = (0 any any)
```
to ~/tcshrc.

And to add the date to the `history` command,




add

```
set histfile = "$HOME/.csh_history"
	set savehist = (5000 merge)
	set history = (5000 "%h %D-%W-%Y %T %R\n")
```
to ~/tcshrc.


----------



## Deleted member 48958 (May 2, 2017)

Here is  my full ~/.tcshrc, with few examples, may be it will be interesting for someone,
Personally I would be very happy if I found post like this when I started with tcsh. 
It's tested and seems to be working fine, few things were taken from shells/tcshrc,
others from tcsh(1) and tcsh.org manuals, or from few some other posts, on the web…

It has some interesting features, for example:
`cd` is an ailas of `pushd`,
so every time you 'cd' into directory, directory saves to the directory stack,
so, for example, you can use `popd` to to return to the previous directory




(to disable printing of the directory stack use `set pushdsilent`.)
(to clean the directory stack use `dirs -c`, to add current dir and list — `dirs -l` [learn more]).
But if you don't need to save directory to directory stack,
just don't use `cd`, "implicitcd" option is enabled,
so you do not need to use `cd` to change directories,
just type path




Also "`cd`" without arguments takes you to your home dir, because "pushdtohome" option is enabled.



```
# update and save history after each command
alias postcmd	'history -S'
```
 It works like "setopt SHARE_HISTORY"  in zsh, it should be placed at the end of ~/.tcshrc.


Also I use security/doas with some apps,
so I got few aliases for it,

```
# doas alias-es
alias vm	'doas vm'
alias ezjail	'doas ezjail-admin'
```
So with it I can use sysutils/vm-bhyve and sysutils/ezjail without `sudo`,
to manipulate bhyve virtual machines and jails. To make it possible you need to install security/doas,
also you need to create /usr/local/etc/doas.conf:

```
permit nopass keepenv :wheel cmd vm
permit nopass keepenv :wheel cmd ezjail-admin
```
 your user should be in a wheel group — `# pw groupmod wheel -m [i]username[/i]`
(relogin after this command, to update your groups),







"autorehash" option is set to "always", so you don't need to type `rehash` manually after each package installation,
because the list of available commands will be rebuilt, for each command completion or spelling correction attempt.


"LSCOLORS" environment variable sets colors in cli apps, like /bin/ls,
you can create your own color set here.


"correct" option is set, so spelling-correction works,
you can edit your "correct" message with (it is a default value)
	
	



```
set prompt3 = "CORRECT>%R (y|n|e|a)?"
```







"listjobs" option is set, so all active jobs will be listed when your current job is suspended (use ctrl+z to suspend).





With "listflags" option, you can add flags to "autolist" (ls-F, builtin ls), which is called by TAB key,
for example, 
	
	



```
set listflags  = a
```

Full ~/.tcshrc:


Spoiler





```
# # # .tcshrc - tcsh resource script, read at beginning of execution by each shell # # #

# skip configuration if shell is not an interactive shell
if ( $?prompt3 == 0 ) exit

setenv		EDITOR		'vim'
setenv		PAGER		'less'
setenv		LESS		'-Airs'
setenv		GREP_COLOR	'1;31'
setenv		CLICOLOR	'1'
setenv		LSCOLORS	'cxfxdxbxexeafaachcagbg'

set path = ( $path $HOME/.local/bin )
set prompt = " %{\033[0;32m%}%C%{\033[0m%} %# "
set prompt3 = "	%R ? (y|n|e|a) "
set promptchars = "%#"
set history = (2000 "%h %D.%W %T %R\n")
set savehist = (2000 merge)
set histfile = "$HOME/.history"
set histdup = erase		 # erase duplicate history events
set watch = (0 any any)		 # notify when someone logs in or out
set who = "%n %a %l from %m"	 # format for watch messages
set notify			 # notification when jobs change state
set listjobs			 # all jobs are listed when a job is suspended
set implicitcd			 # change directory without cd
set symlinks = chase		 # symbolic link is expanded to the real name of the directory
set autocorrect			 # spell-word editor command is invoked automatically
set autoexpand			 # run expand-history before each completion attempt
set autolist = ambiguous	 # choices are listed only when completion fails
set autorehash = always		 # update $PATH after each completion or spelling correction attempt
set correct = cmd		 # commands are automatically spelling-corrected
set complete = enhance		 # completion ignores case and considers hyphens and underscores
set matchbeep = nomatch		 # beeps only when there is no match
set color			 # enables colors for the builtin autolist (TAB)
set rmstar			 # user is prompted before `rm *' is executed
set pushdtohome			 # pushd without arguments does `pushd ~'
#set listflags  = a		 # flags for autolist (TAB)
#set colorcat			 # enables color escape sequence for NLS message files (to make it work, you need to define COLORCAT in /usr/src/contrib/tcsh/config_f.h and recompile tcsh (rebuild world))
# format of `time' command
set time=(8 "\
Time spent in user mode       : %Us\
Time spent in kernel mode     : %Ss\
Total time                    : %Es\
CPU utilisation (percentage)  : %P\
Times the process was swapped : %W\
Times of major page faults    : %F\
Times of minor page faults    : %R")

alias cd	'pushd'
alias c		'cat'
alias q		'exit'
alias h		'history 25'
alias j		'jobs -l'
alias f		'psearch'
alias F		'find . -type f'
alias ff    	'find . -name $*'
alias p		'cd /usr/ports && cd'			 # use it like "p www/firefox"
alias grep	'grep --color'
alias gnugrep	'/usr/local/bin/grep --color'
alias g		'grep -i'
alias v		'vim'
alias .		'pwd'
alias ...	'../..'
alias ls	'ls -F'
alias la	'ls -a'
alias ll	'ls -lht'
alias l		'ls'
alias mkdir	'mkdir -p'
alias s		'sudo'
alias ss	'sudo su -'
alias stat	'stat -x'
alias date	'date +"%d-%m-%Y, %H:%M"'
alias tkill	'tmux kill-session -t'
alias cputemp	'sysctl -a | grep "dev.cpu.*.temperature"'
# doas alias-es
alias vm		'doas vm'
alias ezjail-admin	'doas ezjail-admin'

bindkey -k up history-search-backward	 # up
bindkey -k down history-search-forward	 # down
bindkey '\e[1;5A' i-search-back		 # ctrl+up
bindkey '\e[1;5B' i-search-fwd		 # ctrl+down
bindkey '\e[3~' delete-char		 # delete
bindkey '\e[1;5D' backward-word		 # ctrl+left
bindkey '\e[1;5C' forward-word		 # ctrl+right
bindkey '\e[3;3~' delete-word		 # alt+delete
bindkey '\e[1;3C' delete-word		 # alt+right
bindkey '\e[1;3D' backward-delete-word	 # alt+left
bindkey "\e[1~" beginning-of-line	 # home
bindkey "\e[4~" end-of-line		 # end
# rxvt key bindings
bindkey '\eOd' backward-word		 # ctrl+left
bindkey '\eOc' forward-word		 # ctrl+right
bindkey '\e^[[3~' delete-word		 # alt+delete
bindkey '\e^[[C' delete-word		 # alt+right
bindkey '\e^[[D' backward-delete-word	 # alt+left
bindkey "\e[7~" beginning-of-line	 # home
bindkey "\e[8~" end-of-line		 # end

# start tmux with shell
#if (! $?TMUX) exec tmux -l2

# update and save history after each command
alias postcmd	'history -S'
```


----------



## teo (Nov 27, 2017)

ILUXA said:


> finally… "csh shell history is puzzled", because of this problem I've even switched to zsh.
> But it seems that new version doesn't have this problem anymore.
> 
> But I'm really missing one feature,
> ...



Hello ILUXA!

With csh(1) you cannot remove ~ and @ symbols? And can you change with csh(1) the color of user and root? Sorry I'm very confused about this, give me a hand how to proceed with csh(1), I use csh  on UFS  files for FreeBSD system  of  64-bit.


----------



## Deleted member 48958 (Nov 27, 2017)

Hello. Add
	
	



```
set prompt = "%{\033[0;32m%}%C%{\033[0m%} %# "
```
to ~/.cshrc and 
	
	



```
set prompt = "%{\033[0;31m%}%C%{\033[0m%} %# "
```
to /root/.cshrc.


But if you want to be able to solve your problems by yourself,
you need to READ (for example links that I provided to you in another topic)
and to analyze that you were reading, without this, you'll never be able to solve any issue.


----------



## rigoletto@ (Nov 27, 2017)

Nothing special: .cshrc


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


alias df   df -H
alias h       history 25
alias j       jobs -l
alias la   ls -aF
alias lf   ls -FA
alias ll   ls -lAF


if ( -X nvim ) then
   setenv   EDITOR   nvim
   alias   vi   nvim
else if (-X vi) then
   setenv   EDITOR   vi
endif


setenv   BLOCKSIZE       M
setenv    CLICOLOR       1
setenv   PAGER           more

setenv   TERMINAL       urxvtc
setenv   PANEL_FIFO       /tmp/panel-fifo
setenv   QT_QPA_PLATFORMTHEME   qt5ct
setenv   XDG_MENU_PREFIX       lxde-


if ($?prompt) then

   set autoexpand
   set color
   set colorcat
   set filec
   set autolist    = ambiguous
   set correct    = cmd
   set history    = 2048
   set histfile    = ~/.csh_history
   set mail    = (/var/mail/$USER)
   set savehist   = (1024 merge)
   
   set autorehash    = always

   set grey    = "%{\033[1;30m%}"
   set red    = "%{\033[1;31m%}"
   set green    = "%{\033[1;32m%}"
   set yellow    = "%{\033[1;33m%}"
   set blue    = "%{\033[1;34m%}"
   set magenta    = "%{\033[1;35m%}"
   set cyan    = "%{\033[1;36m%}"
   set white    = "%{\033[1;37m%}"

   set end    = "%{\033[0m%}"

       if ($tty =~ ttyv*) then

           if ( $USER == root ) then
               set prompt = "\n${blue}%~ ${red}%N@%m: \n>>>${end} "
           else
               set prompt = "\n${red}%~ ${blue}%m: \n>>>${end} "
           endif

       else

           if ( $USER == root ) then
               set prompt = "\n${blue}%~ ${red}%N@%m: \n❱❱❱${end} "
           else
               set prompt = "\n${red}%~ ${blue}%m: \n❱❱❱${end} "
           endif

       endif

   unset grey red green yellow blue magenta cyan white end
   
   if ( $?tcsh ) then
           bindkey "^[Od"       backward-word       # rxvt
           bindkey "^[Oc"       forward-word       # rxvt
           bindkey   "\e[2~"       overwrite-mode
           bindkey   "\e[3~"       delete-char
           bindkey   "\e[1;5C"   forward-word
           bindkey   "\e[1;5D"   backward-word
           bindkey   "\e[5~"       history-search-backward
           bindkey   "\e[6~"       history-search-forward
           bindkey   "^W"       backward-delete-word
   endif
   
endif
```


----------



## uzsolt (Nov 29, 2017)

~/.cshrc

```
alias ls	ls -G
alias ls  ls -G
alias svn /usr/bin/svnlite
alias svnadmin /usr/bin/svnliteadmin
alias svnlook /usr/bin/svnlitelook
alias svnsync /usr/bin/svnlitesync
alias time  /usr/bin/time

setenv CLICOLOR 1
setenv EDITOR vim
setenv LANG hu_HU.UTF-8
setenv LC_ALL hu_HU.UTF-8
setenv LESS "-Ri"
setenv LSCOLORS GefhcxdxgXegedabagacad
setenv PAGER less
setenv PATH /sbin/:/usr/sbin/:/usr/bin:/bin:/usr/local/libexec/ccache:/home/zsolt/bin:/usr/local/bin:/sbin/:/usr/sbin/:/home/zsolt/bin:/usr/local/bin

if ($?prompt) then
  # An interactive shell -- set some stuff up

  set addsuffix
  set filec
  set history = 1000
  set savehist = (1000 merge)
  set autolist = ambiguous
  # Use history to aid expansion
  set autoexpand
  set autorehash
  set color
  set noding
  set coredumpsize = 0
  if ( $?tcsh ) then
    bindkey "^W" backward-delete-word
    bindkey -k up history-search-backward
    bindkey -k down history-search-forward
  endif
endif

set coredumpsize=0
```

~/.login

```
complete git \
  'p/1/(add commit rm status diff push pull)/' \
  'n@diff@`git status -s | sed -n "/^ M/ s,^ M ,,p"`@' \
  'n@add@`git status -s | sed -n "/^??/ s,^?? ,,p"`@' \
  'n@commit@`git status -s | sed -n "/^[A ]/ s,^...,,p" ; echo .`@' \
  'n@push@`git remote`@'

set mandir="/usr/share/man/man* /usr/local/man/man*"
set pdf="f:*.[pP][dD][fF]"

complete cd \
  'p/1/d/'

complete chown \
  'p/1/u/'

complete complete \
  'p/1/X/'

complete dd \
  'c/[io]f=/f/ n/*/"(if of ibs obs bs skip seek count)"/='

complete doas \
  'p@1@`sed "s,.*cmd *\([^ ]*\).*,\1," /usr/local/etc/doas.conf`@'

complete find \
  'n/-fstype/"(nfs 4.2)"/' 'n/-name/f/' \
  'n/-type/(c b d f p l s)/' \
  'n/-user/u/ n/-group/g/' \
  'n/-exec/c/' 'n/-ok/c/' \
  'n/-cpio/f/' \
  'n/-ncpio/f/' \
  'n/-newer/f/' \
  'c/-/(fstype name perm prune type user nouser group nogroup size inum atime mtime ctime exec \
    ok print ls cpio ncpio newer xdev depth daystart follow maxdepth mindepth noleaf version \
    anewer cnewer amin cmin mmin true false uid gid ilname iname ipath iregex links lname empty path \
    regex used xtype fprint fprint0 fprintf print0 printf not a and o or)/' \
  'n/*/d/'

complete gpart \
  'p/1/(add backup bootcode commit create delete destroy modify recover resize restore set show undo unset)/' \
  'n/add/x:-t type [-a alignment] [-b start] [-s size] [-i index] [-l label] -f flags geom/' \
  'n/backup/x:geom/' \
  'n/bootcode/x:[-b bootcode] [-p partcode -i index] [-f flags] geom/' \
  'n/commit/x:geom/' \
  'n/create/x:-s scheme [-n entries] [-f flags] provider/' \
  'n/delete/x:-i index [-f flags] geom/' \
  'n/destroy/x:[-F] [-f flags] geom/' \
  'n/modify/x:-i index [-l label] [-t type] [-f flags] geom/' \
  'n/recover/x:[-f flags] geom/' \
  'n/resize/x:-i index [-a alignment] [-s size] [-f flags] geom/' \
  'n/restore/x:[-lF] [-f flags] provider [...]/' \
  'n/set/x:-a attrib -i index [-f flags] geom/' \
  'n/show/x:[-l | -r] [-p] [geom ...]/' \
  'n/undo/x:geom/' \
  'n/unset/x:-a attrib -i index [-f flags] geom/'

complete grep \
  'c/-*A/x:<#_lines_after>/' \
  'c/-*B/x:<#_lines_before>/' \
  'c/--/(extended-regexp fixed-regexp basic-regexp regexp file ignore-case word-regexp line-regexp \
    no-messages revert-match version help byte-offset line-number with-filename no-filename quiet silent \
    text directories recursive files-without-match files-with-matches count before-context after-context \
    context binary unix-byte-offsets)/' \
  'c/-/(A a B b C c d E e F f G H h i L l n q r s U u V v w x)/' \
  'p/1/x:<limited_regular_expression>/ N/-*e/f/' \
  'n/-*e/x:<limited_regular_expression>/' \
  'n/-*f/f/' \
  'n/*/f/'

complete herbstclient \
  'p/*/`set cmd="${COMMAND_LINE}x"; \
    set cmd=( ${cmd:s,herbstclient,,} ); \
    set cmd_nr=${#cmd} ; \
    @ cmd_nr-- ; \
    herbstclient complete_shell ${cmd_nr} ${COMMAND_LINE:s,herbstclient,,}`/'

complete ifconfig \
  'p@1@`ifconfig -l`@' \
  'n/*/(range phase link netmask mtu vlandev vlan metric mediaopt down delete broadcast arp debug)/' \
  'c/%/j/' \
  'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/'

complete kill \
  'c/-/S/' \
  'c/%/j/' \
  'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/'

complete killall \
  'c/-/S/' \
  'c/%/j/' \
  'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/'

complete kldload \
  'n@*@`ls -1 /boot/modules/ /boot/kernel/ | awk -F/ \$NF\ \~\ \".ko\"\ \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\}`@'

complete kldunload \
  'n@*@`kldstat | awk \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\} | grep -v Name`@'

complete localc \
  'p/*/f:*.{xls,xlsx}/'

complete lowriter \
  'p/*/f:*.{doc,docx}/'

complete make \
  'p@1@`make -V.ALLTARGETS`@'

complete man \
  'C@*@`find ${mandir} -type f -name \*.gz | sed "s,.*/,, ; s,\.[^\.]*\.gz,,"`@'

complete mupdf \
  "p/*/${pdf}/"

complete okular \
  "p/*/${pdf}/"

complete pdflatex \
  'p/*/f:*.tex/'

complete service \
  'c/-/(e l r v)/' \
  'p/1/`service -l`/' \
  'n/*/(start stop reload restart status rcvar onestart onestop)/'

complete sysctl \
  'n/*/`sysctl -Na`/'

complete tmux \
  'n/*/(attach detach has kill-server kill-session lsc lscm ls lockc locks new refresh rename showmsgs source start suspendc switchc)/'

set _task_date="modified.after:2016-01-01"
complete task \
  'c/pri:/(L M H)/' \
  'c/project:/`task ${_task_date} _unique project`/' \
  'n/[0-9]*/(annotate edit modify done)/' \
  'p/2-/(project pri due)/:/' \
  'p/1/`echo add list ; task _unique id`/'

complete unrar \
  'p/*/f:*.rar/'

complete unzip \
  'p/*/f:*.zip/'

complete which \
  'C/*/c/'

complete zathura \
  "p/*/${pdf}/"

alias _comp_pkgs 'pkg info -q'
alias _comp_pkg_info '_comp_pkgs | xargs echo --list-files --pkg-message --comment --dependencies --required-by --size'
alias _comp_pkg_install 'sqlite3 /var/db/pkg/repo-FreeBSD.sqlite "select name from packages;"'

complete pkg \
  'p/1/(annotate autoremove delete info install iv rquery ri rv rw query search uv ur which)/' \
  'n/info/`_comp_pkg_info`/' \
  'N/info/`_comp_pkgs`/' \
  'n/delete/`_comp_pkgs`/' \
  'n/install/`_comp_pkg_install`/' \
  'n/rv/`pkg rquery "%n" | uniq`/' \
  'n/ri/`pkg rquery "%n" | uniq`/' \
  'n/rw/`pkg rquery "%n" | uniq`/' \

set _svn_commands=( add blame cat checkout cleanup commit copy delete diff export help import info \
  list ls lock log merge mkdir move propdel propedit propget proplist propset \
  resolved revert status switch unlock update )
set _svnsync_commands=( init sync copy-revprops info help )
set _svnsync_list=( \
  file:///home/storage/svn/server-dotfiles \
  file:///home/storage/svn/uzsolt.hu/ \
  svn+ssh://svn@svn.uzsolt.hu/usr/local/subversion/dokumentumok \
  svn+ssh://svn@svn.uzsolt.hu/usr/local/subversion/homefiles \
  svn+ssh://svn@svn.uzsolt.hu/usr/local/subversion/svnadmin \
  svn+ssh://svn@svn.uzsolt.hu/usr/local/subversion/texmf_own \
  )
set _svn_props=( svn:global-ignores svn:ignore svn:log )
alias _comp_svn_modified 'svn status | sed -n "/^[AM]/ s,^[AM] *,,p"'
alias _comp_svn_new 'svn status | sed -n "/^?/ s,^? *,,p"'

complete svn \
  'p@1@$_svn_commands@' \
  'c@file://@d@' \
  'n@checkout@(file:// svn+ssh:// svn://)@@' \
  'n@help@$_svn_commands@' \
  'n@ls@(file:// svn+ssh:// svn:// ^/)@@' \
  'n@add@`_comp_svn_new`@' \
  'n@commit@`_comp_svn_modified`@' \
  'n@diff@`_comp_svn_modified`@' \
  'n@propedit@$_svn_props@' \
  'n@propget@$_svn_props@' \
  'n@propset@$_svn_props@' \
  'N@propedit@d@' \
  'n@revert@`svn status | sed -n "/^[ADM]/ s,^[ADM] *,,p"`@' \
  'n@status@`svn status | sed -n "/^[ADM?]/ s,^[ADM?] *,,p"`@'

complete svnadmin \
  'p@1@(crashtest create deltify dump freeze help  hotcopy list-dblogs list-unused-dblogs load lock lslocks lstxns pack recover \
    rmlocks rmtxns setlog setrevprop setuuid unlock upgrade verify)@' \
  'n@create@d@' \
  'n@dump@d@'

complete svnsync \
  'p@1@$_svnsync_commands@' \
  'n@help@$_svnsync_commands@' \
  'n@sync@$_svnsync_list@'


set     red="%{\033[1;31m%}"
set   green="%{\033[0;32m%}"
set  yellow="%{\033[1;33m%}"
set    blue="%{\033[1;34m%}"
set magenta="%{\033[1;35m%}"
set    cyan="%{\033[1;36m%}"
set   white="%{\033[0;37m%}"
set     end="%{\033[0m%}"

set HOSTCOLOR="${green}"
set promptchars='$#'
set prompt = "\n${HOSTCOLOR}%M ${white}|${cyan} %T ${white}| ${cyan}%~${end} \n"
set prompt="${prompt}$ ${end}"

alias use-sb 'setenv SANDBOX `mktemp -d /home/zsolt/sandbox/sandbox.XXXXXXXX` ; tcsh -l ; rm -rf ${SANDBOX} ; unsetenv SANDBOX'

setenv XDG_CONFIG_HOME /home/zsolt/.config/
setenv XDG_DATA_HOME ${XDG_CONFIG_HOME}
setenv XDG_CACHE_HOME /home/zsolt/.cache/

setenv WCDHOME ${XDG_CONFIG_HOME}/wcd
alias wcd "/usr/local/bin/wcd \!* ; source ${WCDHOME}/bin/wcd.go"

if ($tty == "ttyv0") then
  setenv _JAVA_AWT_WM_NONREPARENTING 1
  echo Starting Xorg...
  startx #&> /home/users/zsolt/logfiles/startx.log
  echo "Halt (h) Reboot (r) Nothing (n) ?"
  set answer = $<
  if ($answer == "h") then
    /sbin/shutdown -p now
  else if ($answer == "r") then
    /sbin/shutdown -r now
  endif
else
  if (${?SANDBOX} == 1) then
    set prompt = "${green}%n ${white}|${cyan} %T ${white}| ${yellow}%~${end} \n${magenta}<sandbox>${blue} $ ${end} "
    cd ${SANDBOX}
  else if (${?BURN} == 1) then
    cd ${BURN}
    set prompt = "${green}%n ${white}|${cyan} %T ${white}| ${yellow}%~${end} \n${magenta}<burn>${blue} $ ${end} "
    alias precmd du-tmp-burn
  else
    # /usr/games/fortune freebsd-tips | cowsay -n
    if (${?TMUX_PANE} == 1) then
      if (${TMUX_PANE} == "%0") then
        set updatingdate = `date -v-1w +%Y%m%d`
        set tmpfile = `mktemp -t pkgupdating`
        if (`pkg updating -d ${updatingdate} | tee ${tmpfile} | wc -l` > 0) then
          cat ${tmpfile} | cowthink -n -f default | histring -E "^ [-_]*|.*AFFECTS.*|^\( [0-9]{8}:.*" -c green #| cowthink -n
        endif
        rm ${tmpfile}
      endif
    endif
    task list due.before:20d
    task list due.after:20d
  endif
endif

set printexitvalue
```


----------



## DenisVS (Mar 7, 2018)

*jexec*

```
complete jexec  'p@1@`jls -N | awk \{\ print\ \$1\ \} | grep -v JID`@'
```


```
# jexec
backtunnels mariadb55   murmur      nginx       php54       proxies
devel       messengers  myservices  php52       php71
```


----------



## uzsolt (Mar 8, 2018)

https://svn.uzsolt.hu/server-dotfiles/trunk/home/


----------



## grahamperrin@ (Jun 11, 2022)

*~/.cshrc*

From the first line, I assume that it originated in 2018. 

Nothing extraordinary. Some of it seems to not work as expected, I'll take this to a separate topic.


```
# $FreeBSD: head/share/skel/dot.cshrc 337497 2018-08-08 19:24:20Z asomers $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
# more examples available at /usr/share/examples/csh/
#

alias h         history 25
alias j         jobs -l
alias la        ls -aF
alias lf        ls -FA
alias ll        ls -lAF
alias ft        'cat /usr/share/games/fortune/freebsd-tips | grep '
alias tb        'nc termbin.com 9999'
# <https://wiki.freebsd.org/Phabricator#Install_Command_Line_Client>
alias arc       /usr/local/lib/php/arcanist/bin/arc
# complete ft   'cat /usr/share/games/fortune/freebsd-tips | grep '

# These are normally set through /etc/login.conf.  You may override them here
# if wanted.
set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin $HOME/bin $HOME/.local/bin)
setenv  BLOCKSIZE       M
# A righteous umask
# umask 22

# <https://www.freshports.org/x11-themes/classiclooks/#message>
# setenv        QT_QPA_PLATFORMTHEME    gtk2

setenv  EDITOR  /usr/local/bin/nano
setenv  VISUAL  /usr/local/bin/nano
# setenv        MANPAGER        "less -sR"
# <https://unix.stackexchange.com/a/319231/13260>
setenv  MANCOLOR        1
setenv  MANWIDTH        tty
# setenv        PAGER   less
# setenv        PAGER   more
#
# 2021-03-25 ""
# setenv        TERM    xterm1

if ($?prompt) then
        # An interactive shell -- set some stuff up
#       set prompt = "%N@%m:%~ %# "
        set prompt = "%# "
        set promptchars = "%#"

        set filec
        set history = 2000
        set savehist = (2000 merge)
        set autolist = ambiguous
        # Use history to aid expansion
        set autoexpand
        set autorehash
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
#               bindkey '\e[1~'         beginning-of-line
#               bindkey '\e[4~'         end-of-line
                bindkey '\e[3~'         delete-char
#               bindkey '\e[5~'         beginning-of-history
#               bindkey '\e[6~'         end-of-history
#               bindkey '\e[2~'         quoted-insert
#               bindkey '\e[5C'         forward-word
#               bindkey '\e[5D'         backward-word
                bindkey '\e[1;5C'       forward-word
                bindkey '\e[1;5D'       backward-word
        endif

endif

# <https://www.freshports.org/textproc/ibus/#message>
setenv XIM ibus
setenv GTK_IM_MODULE ibus
setenv QT_IM_MODULE ibus 
setenv XMODIFIERS @im=ibus   
setenv XIM_PROGRAM ibus-daemon
setenv XIM_ARGS "--daemonize --xim"

# <https://www.freebsd.org/cgi/man.cgi?query=gpg-agent&sektion=1&manpath=FreeBSD-Ports>
# <https://opensource.com/article/19/4/gpg-subkeys-ssh>
# <https://old.reddit.com/r/freebsd/comments/v5a0wx/-/>
# setenv        GPG_TTY         tty
# setenv        SSH_AUTH_SOCK   `gpgconf --list-dirs agent-ssh-socket`
```


----------

