TCSH config for {Free,Open}BSD, Linux, OpenSolaris (raw, dl) (+1 likes)
Carpetsmoker Nov 06, 2012 (shells/tcsh)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | # $FreeBSD: release/9.0.0/etc/csh.cshrc 50472 1999-08-27 23:37:10Z peter $
# $OpenBSD: csh.cshrc,v 1.2 1996/05/26 10:25:19 deraadt Exp $
#
# tcsh configuration
# Martin Tournoij <martin@arp242.net>
# Should work on: FreeBSD, OpenBSD, Linux, OpenSolaris
# $Config$
#
# NetBSD
if (-d /usr/pkg/bin) then
set prefix = /usr/pkg
# OpenSolaris
else if (-d /opt/csw/bin) then
set prefix = /opt/csw
# FreeBSD, OpenBSD
else if (-d /usr/local/bin) then
set prefix = /usr/local
else
set prefix = 0
endif
set uname = `uname`
##################################################
# Environment
#################################################
umask 022
setenv PATH ~/bin
setenv PATH ${PATH}:/sbin:/bin:/usr/sbin:/usr/bin
if (-d /usr/X11R6/bin) then
setenv PATH ${PATH}:/usr/X11R6/bin:/usr/X11R6/sbin
endif
if (-d /usr/local/bin) then
setenv PATH ${PATH}:/usr/local/bin:/usr/local/sbin
endif
if ($prefix != 0) then
setenv PATH ${PATH}:${prefix}/bin:/${prefix}/sbin
endif
setenv PATH ${PATH}:/usr/games
# Some commonly installed packages on OpenSolaris
if ($uname == SunOS) then
setenv PATH ${PATH}:/opt/VirtualBox
setenv PATH ${PATH}:/opt/csw/gcc4/bin
endif
# /var/ is a memory device on my laptop
if ($uname == FreeBSD && -d /pkgdb) then
setenv PKG_DBDIR /pkgdb/
setenv PKG_TMPDIR /tmp/
endif
# Various applications settings
setenv PAGER less
# --squeeze-blank-lines
# --chop-long-lines
setenv LESS "--ignore-case --LONG-PROMPT --SILENT --tabs=2 --no-init"
setenv BLOCKSIZE K
setenv LS_COLORS "no=00:fi=00:di=34:ln=01;31:pi=34;43:so=31;43:bd=30;43:cd=30;43:or=01;35:ex=01;31:"
setenv GREP_COLOR 31
setenv ACK_COLOR_FILENAME red
if ($uname == OpenBSD) then
# Seems to work better on OpenBSD ...
setenv TERM xterm-xfree86
else if ($uname == FreeBSD) then
if ($tty =~ ttyv*) then
setenv TERM cons25
/usr/sbin/kbdcontrol -r fast
else
setenv TERM xterm-color
endif
else if ($uname == Linux) then
setenv TERM xterm-color
else
setenv TERM vt220
endif
# UTF-8
if (-X locale) then
setenv LANG en_US.UTF-8
setenv LC_CTYPE en_US.UTF-8
endif
if ($uname == FreeBSD) then
setenv CVSROOT ":pserver:anoncvs@anoncvs.fr.FreeBSD.org:/home/ncvs"
else if ($uname == OpenBSD) then
setenv PKG_PATH "ftp://ftp.openbsd.org/pub/OpenBSD/`uname -r`/packages/`uname -m`/"
setenv CVSROOT "anoncvs@anoncvs.fr.openbsd.org:/cvs"
endif
# Set editor
if (-X vim) then
setenv EDITOR vim
alias vi "vim"
else if (-X vi) then
setenv EDITOR vi
endif
# Set browser
if (-X opera) then
setenv BROWSER opera
else if (-X elinks) then
setenv BROWSER elinks
else if (-X links) then
setenv BROWSER links
else if (-X lynx) then
setenv BROWSER lynx
endif
#################################################
# Settings
#################################################
# Basic corrections when completing
set autocorrect
# Show options when autocompleting
set autolist
# Use history to aid expansion
set autoexpand
# Never autologout
set autologout
# Colorize stuff
set color
# set -n and set '\003' will both work
set echo_style=both
# file completion
set filec
# Keep n items in history
set history = 8192
# Logout on ^D
unset ignoreeof
# Show '>' for symlink to dir, and '&' for symlink to nowhere
set listlinks
# List all jobs after ^Z
set listjobs
# Show current dir.
set prompt = "[%~]%# "
# Show date & hostname on right side
set rprompt = "%B%U%m%b%u:%T"
# Never print "DING!" as the time
set noding
# Use % for normal user and # for super
set promptchars = "%#"
# Don't beep
set nobeep
# Don't allow > redirection on existing files (only >>)
set noclobber
# Print exit value if >0
set printexitvalue
# Ask for confirmation if we do rm *
set rmstar
# Save history
set savehist = 8192 merge
# Lists file name suffixes to be ignored by completion
# TODO Doesn't seem to work ... ?
set fignore = (.o .pyc)
#################################################
# Aliases
#################################################
# "Special" aliases
# Update xterm title on directory change
alias cwdcmd 'echo -n "\033]2;tcsh: $cwd\007"'
# Modestly color my ls. But not christmas tree Linux colors! (See environment
# variable $LS_COLOR above)
if ($uname == FreeBSD) then
alias ls "ls-F -I"
alias la "ls-F -A"
alias lc "ls-F -lThoI"
alias lac "ls-F -lThoA"
alias pdiff "diff -urN -x CVS -x .svn -I '^# .FreeBSD: '"
# bsdgrep is FreeBSD >=9
if (-X bsdgrep) then
alias grep "bsdgrep --color"
else
alias grep "grep --color"
endif
else if ($uname == OpenBSD) then
if (-X colorls) then
alias ls "colorls -FG"
alias la "colorls -FGA"
alias lc "colorls -FGlTho"
alias lac "colorls -FGlThoA"
else
alias ls "ls -F"
alias la "ls -FA"
alias lc "ls -FlTho"
alias lac "ls -FAlTho"
endif
alias pdiff "diff -urN -x CVS -x .svn -I '^# .OpenBSD: '"
else if ($uname == SunOS) then
alias ls "ls-F"
alias la "/bin/ls -FA"
alias lc "/bin/ls -Flho"
alias lac "/bin/ls -FlAho"
else if ($uname == Linux) then
unalias ls
alias ls ls-F
alias lc ls -lh
alias la ls -A
alias lac ls -lhA
alias sockstat "netstat -lnptu"
else
# These should work on almost any platform ...
alias la "ls -a"
alias lc "ls -l"
alias lac "ls -la"
endif
# Override the tcsh builtins
if (-x /usr/bin/nice) then
alias nice "/usr/bin/nice"
else if (-x /bin/nice) then
alias nice "/bin/nice"
endif
if (-x /usr/bin/time) then
alias time "/usr/bin/time -h"
endif
# A few move aliases...
alias cp "cp -i"
alias mv "mv -i"
alias make "nice -n 20 make"
alias lman "groff -man -Tascii"
alias j "jobs -l"
# Third-party stuff
if (-X mplayer) then
alias music "mplayer -cache-min 0 $* *.{mp3,flac}"
endif
# Some programs are hard coded to launch firefox ... :-/
if (-X opera) then
alias opera "opera -nomail"
alias firefox "opera"
endif
alias youtube-dl 'youtube-dl -t'
alias turboturbofull 'xfreerdp -x lan -u carpetsmoker -f -o 192.168.3.11'
alias turboturbo 'xfreerdp -x lan -u carpetsmoker -g 1024x768 -o 192.168.3.11'
alias xangband "angband -mx11 -- -n3"
alias xtome "tome -mx11 -- -n3"
if (-X xtermset) then
alias xt "xtermset -title"
alias black "xtermset -fg white -bg black"
alias white "xtermset -fg black -bg white"
else if (-X xtermcontrol) then
alias xt "xtermcontrol --title"
alias black "xtermcontrol --fg=white --bg=black"
alias white "xtermcontrol --fg=black --bg=white"
endif
# Typos
alias sl "ls"
alias l "ls"
alias c "cd"
alias vo "vi"
# I know ci is already a command, but not used often and it mangles files!
alias ci "vi"
alias grpe "grep"
alias Grep "grep"
alias helpcommand man
#################################################
# Keybinds
#################################################
# Delete
bindkey ^[[3~ delete-char
# Home
bindkey ^[[H beginning-of-line
bindkey ^[[1~ beginning-of-line
# End
bindkey ^[[F end-of-line
bindkey ^[[4~ end-of-line
# F1
bindkey ^[[M run-help
bindkey OP run-help
bindkey ^[[11~ run-help # Putty
# Arrow keys
bindkey -k up history-search-backward
bindkey -k down history-search-forward
# Insert
bindkey ^[[L yank
bindkey ^[[2 yank
#################################################
# Completion
#################################################
# Show directories only
complete cd 'C/*/d/'
complete rmdir 'C/*/d/'
complete alias 'p/1/a/'
complete unalias 'p/1/a/'
complete unset 'p/1/s/'
complete set 'p/1/s/'
complete unsetenv 'p/1/e/'
complete setenv 'p/1/e/'
complete limit 'p/1/l/'
complete bindkey 'C/*/b/'
complete chgrp 'p/1/g/'
complete chown 'p/1/u/' # TODO Support user:group completion
complete uncomplete 'p/*/X/'
#complete kill 'c/-/S/' 'p/1/(-)//'
complete kill 'c/-/S/' 'n/*/`ps -axco pid= | sort`/'
complete pkill 'c/-/S/' 'n/*/`ps -axco command= | sort -u`/'
# Use available commands as arguments
complete which 'p/1/c/'
complete where 'p/1/c/'
complete man 'p/1/c/'
complete apropos 'p/1/c/'
complete find \
'n/-name/f/' 'n/-newer/f/' 'n/-{,n}cpio/f/' \
'n/-exec/c/' 'n/-ok/c/' 'n/-user/u/' 'n/-group/g/' \
'n/-fstype/(nfs 4.2)/' 'n/-type/(b c d f l p s)/' \
'c/-/(name newer cpio ncpio exec ok user group fstype type atime \
ctime depth inum ls mtime nogroup nouser perm print prune \
size xdev and or)/' \
'p/*/d/'
complete hg 'p/1/(add annotate clone commit diff export forget init log \
merge phase pull push remove serve status summary update)/'
complete svn 'p/1/(add blame cat changelist checkout cleanup commit copy \
delete diff export help import info list lock log merge mergeinfo \
mkdir move propdel propedit propget proplist propset resolve \
resolved revert status switch unlock update)/'
# Only list make targets
complete make 'n@*@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; s/[[:blank:]]*:.*//gp;"`@'
# set up programs to complete only with files ending in certain extensions
complete cc 'p/*/f:*.[cao]/'
complete python 'p/*/f:*.py/'
complete perl 'p/*/f:*.[pP][lL]/'
#complete sh 'p/*/f:*.sh/'
# set a list of hosts
complete ssh 'p@1@`cut -d " " -f 1 ~/.ssh/known_hosts | sort -u`@'
# complete [command [word/pattern/list[:select]/[[suffix]/] ...]] (+)
if ($uname == FreeBSD) then
complete sysctl 'n/*/`sysctl -Na`/'
complete service 'n/*/`service -l`/'
complete pkg_delete 'c/-/(i v D n p d f G x X r)/' 'n@*@`/bin/ls /var/db/pkg`@'
else if ($uname == Linux) then
# Use /bin/ls to prevent ls options interfering (i.e. adding a *)
complete service 'n@*@`/bin/ls /etc/init.d`@'
complete chkconfig 'c/--/(list add del)/' 'n@*@`/bin/ls /etc/init.d`@'
endif
|
x
Notes
This is my tcsh config which should work on at least FreeBSD, OpenBSD, Linux, and OpenSolaris.
It doesn’t use every possible option in tcsh, only those that I like :-) Also adds some completions and stuff.
Latest version should always be available from bitbucket:
https://bitbucket.org/Carpetsmoker/config/src