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