xref: /freebsd/share/examples/csh/dot.cshrc (revision 2aa00a6001d7105eaf0d0288a441fa69f06fa534)
1# Here are some example (t)csh options and configurations that you may find interesting
2#
3# $FreeBSD$
4#
5
6# Sets SSH_AUTH_SOCK to the user's ssh-agent socket path if running
7#
8# This has a couple caveats, the most notable being that if a user
9# has multiple ssh-agent(1) processes running, this will very likely
10# set SSH_AUTH_SOCK to point to the wrong file/domain socket.
11if (${?SSH_AUTH_SOCK} != "1") then
12	setenv SSH_AUTH_SOCK `sockstat -u | awk '/^${USER}.+ ssh-agent/ { print $6 }'`
13endif
14
15# Change only root's prompt
16if (`id -g` == 0) then
17	set prompt="root@%m# "
18endif
19
20# This maps the "Delete" key to do the right thing
21# Pressing CTRL-v followed by the key of interest will print the shell's
22# mapping for the key
23bindkey "^[[3~" delete-char-or-list-or-eof
24
25# Make the Ins key work
26bindkey "\e[2~" overwrite-mode
27
28# Some common completions
29complete cd		'p/1/d/'
30complete chown          'p/1/u/'
31complete dd		'c/[io]f=/f/ n/*/"(if of ibs obs bs skip seek count)"/='
32complete find 	'n/-fstype/"(nfs 4.2)"/' 'n/-name/f/' \
33      	  	'n/-type/(c b d f p l s)/' \
34      		'n/-user/u/ n/-group/g/' \
35      		'n/-exec/c/' 'n/-ok/c/' \
36      		'n/-cpio/f/' \
37      		'n/-ncpio/f/' \
38      		'n/-newer/f/' \
39      	  	'c/-/(fstype name perm prune type user nouser group nogroup size inum atime mtime ctime exec \
40      		  ok print ls cpio ncpio newer xdev depth daystart follow maxdepth mindepth noleaf version \
41      		  anewer cnewer amin cmin mmin true false uid gid ilname iname ipath iregex links lname empty path \
42      		  regex used xtype fprint fprint0 fprintf print0 printf not a and o or)/' \
43      		'n/*/d/'
44complete fg		'c/%/j/'
45complete gpart	'p/1/(add backup bootcode commit create delete destroy modify recover resize restore set show undo unset)/' \
46			'n/add/x:-t type [-a alignment] [-b start] [-s size] [-i index] [-l label] -f flags geom/' \
47      		'n/backup/x:geom/' \
48      		'n/bootcode/x:[-b bootcode] [-p partcode -i index] [-f flags] geom/' \
49      		'n/commit/x:geom/' \
50      		'n/create/x:-s scheme [-n entries] [-f flags] provider/' \
51      		'n/delete/x:-i index [-f flags] geom/' \
52      		'n/destroy/x:[-F] [-f flags] geom/' \
53      		'n/modify/x:-i index [-l label] [-t type] [-f flags] geom/' \
54      		'n/recover/x:[-f flags] geom/' \
55      		'n/resize/x:-i index [-a alignment] [-s size] [-f flags] geom/' \
56      		'n/restore/x:[-lF] [-f flags] provider [...]/' \
57      		'n/set/x:-a attrib -i index [-f flags] geom/' \
58      		'n/show/x:[-l | -r] [-p] [geom ...]/' \
59      		'n/undo/x:geom/' \
60      		'n/unset/x:-a attrib -i index [-f flags] geom/'
61complete grep		'c/-*A/x:<#_lines_after>/' \
62      		'c/-*B/x:<#_lines_before>/' \
63      		'c/--/(extended-regexp fixed-regexp basic-regexp regexp file ignore-case word-regexp line-regexp \
64      		  no-messages revert-match version help byte-offset line-number with-filename no-filename quiet silent \
65      		  text directories recursive files-without-match files-with-matches count before-context after-context \
66      		  context binary unix-byte-offsets)/' \
67      		'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)/' \
68      		'p/1/x:<limited_regular_expression>/ N/-*e/f/' \
69      		'n/-*e/x:<limited_regular_expression>/' \
70      		'n/-*f/f/' \
71      		'n/*/f/'
72complete ifconfig	'p@1@`ifconfig -l`@' \
73      		'n/*/(range phase link netmask mtu vlandev vlan metric mediaopt down delete broadcast arp debug)/' \
74      		'c/%/j/' \
75      		'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/'
76complete kill		'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/'
77complete killall	'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $5}'"'"'`/'
78complete kldload	'n@*@`ls -1 /boot/modules/ /boot/kernel/ | awk -F/ \$NF\ \~\ \".ko\"\ \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\}`@'
79complete kldunload	'n@*@`kldstat | awk \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\} | grep -v Name`@'
80complete make		'p@1@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; s/[[:blank:]]*:.*//gp;"`@' \
81      			'n@-V@`make -ndv | & grep Global: | sed -E -e "s/^Global://" -e "s/ .*//" -e "/^[[:lower:]]/d" | sort | uniq`@'
82complete man		'C/*/c/'
83complete netstat	'n@-I@`ifconfig -l`@'
84complete pkg_delete     'c/-/(i v D n p d f G x X r)/' 'n@*@`ls /var/db/pkg`@'
85complete 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/%%`@'
86complete ping		'p/1/$hosts/'
87complete pkill		'c/-/S/' \
88      			'n@*@`ps -axc -o command="" | sort | uniq`@'
89complete portmaster	'c/--/(always-fetch check-depends check-port-dbdir clean-distfiles clean-packages delete-build-only \
90      		  delete-packages force-config help index index-first index-only list-origins local-packagedir \
91      		  no-confirm no-index-fetch no-term-title packages packages-build packages-if-newer packages-local \
92      		  packages-only show-work update-if-newer version)/' \
93      		'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)/' \
94      		'n@*@`pkg_info -E \*`@'
95complete rsync	"c,*:/,F:/," \
96      		"c,*:,F:$HOME," \
97      		'c/*@/$hosts/:/'
98complete scp	"c,*:/,F:/," \
99      		"c,*:,F:$HOME," \
100      		'c/*@/$hosts/:/'
101complete service  	'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/'
102complete svn		'C@file:///@`'"${HOME}/etc/tcsh/complete.d/svn"'`@@' \
103      		'n@ls@(file:/// svn+ssh:// svn://)@@' \
104      		'n@help@(add blame cat checkout cleanup commit copy delete export help import info list ls lock log merge mkdir move propdel \
105      		  propedit propget proplist propset resolved revert status switch unlock update)@' 'p@1@(add blame cat checkout cleanup commit \
106      		  copy delete export help import info list ls lock log merge mkdir move propdel propedit propget proplist propset resolved \
107      		  revert status switch unlock update)@'
108complete ssh	'p/1/$hosts/' \
109      		'c/-/(l n)/' \
110      		'n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/'
111complete sysctl 'n/*/`sysctl -Na`/'
112complete tmux	'n/*/(attach detach has kill-server kill-session lsc lscm ls lockc locks new refresh rename showmsgs source start suspendc switchc)/'
113complete which	'C/*/c/'
114
115if ( -f /etc/printcap ) then
116  set printers=(`sed -n -e "/^[^ 	#].*:/s/:.*//p" /etc/printcap`)
117  complete lpr	'c/-P/$printers/'
118  complete lpq	'c/-P/$printers/'
119  complete lprm	'c/-P/$printers/'
120endif
121
122# Alternate prompts
123set prompt = '#'
124set prompt = '%B%m%b%# '
125set prompt = '%B%m%b:%c03:%# '
126set prompt = '%{\033]0;%n@%m:%/\007%}%B%m%b:%c03:%# '
127set prompt = "%n@%m %c04%m%# "
128set prompt = "%n@%m:%c04 %# "
129set prompt = "[%n@%m]%c04%# "
130set ellipsis
131
132# Color ls
133alias ll	ls -lAhG
134alias ls	ls -G
135
136# Color on many system utilities
137setenv CLICOLOR 1
138
139# other autolist options
140set		autolist = TAB
141