# .tcsh setup file -*- mode: shell-script; -*- # # $Id: dot-tcshrc,v 1.80 2006/02/15 23:02:33 simon Exp $ # # by Simon L. Nielsen # ##################################################################### ## User configuration (can be overridden in ~/.tcshrc.conf) : ##################################################################### # Might be needed by config if(${?HOST} && -z "${HOST}") then setenv HOST `hostname` endif # Do we want colors on ls e.g.? set SHELLCOLOR=0 # Default prompt set DEFAULT_PROMPT="[%n@%m:%c] " # Enable special xterm title change? set XTERM_TITLE_PROMPT=1 # What should be in the xterm title set XTERM_TITLE="%n@%m:%~" # Should toolchain be used if avaliable? set USE_KEYCHAIN=0 set KEYCHAIN_SH_FLE="${HOME}/.keychain/${HOST}-csh" set KEYCHAIN_QUIET=1 # Which file should output from fw reload be put in set FW_OUT_FILE="/root/fw_reload.out" # Display a non default hostname #DISPLAY_HOSTNAME_OVERRIDE="" # Read custom config if(-r "${HOME}/.tcshrc.conf") then source "${HOME}/.tcshrc.conf" endif if(! ${?MAIN_EMAIL_ADDR}) then setenv MAIN_EMAIL_ADDR "`whoami`@`hostname`" endif ##################################################################### ## Set var correct depending on user options ##################################################################### # Change PROMPT if hostname overridden if(${?DISPLAY_HOSTNAME_OVERRIDE}) then set DEFAULT_PROMPT=`echo "${DEFAULT_PROMPT}" | sed "s/%m/${DISPLAY_HOSTNAME_OVERRIDE}/g"` set DEFAULT_PROMPT="${DEFAULT_PROMPT} " # Add trailing space again # What should be in the xterm title set XTERM_TITLE=`echo "${XTERM_TITLE}" | sed "s/%m/${DISPLAY_HOSTNAME_OVERRIDE}/g"` endif ##################################################################### ## Set var correct depending on local system ##################################################################### # Make rest of script stop complaining about misc unset vars if(! ${?TERM}) setenv TERM "" if(! ${?OSTYPE}) setenv OSTYPE "" # Reset key-bindings to emacs style bindkey -e # When we su USER does not get set correctly if(-x `which whoami`) then setenv USER `whoami` endif # I like jove/emacs :) if(-x `which jove`) then setenv EDITOR jove endif if(-x `which emacs`) then setenv P4EDITOR emacs endif # I like less better than more if(-x `which less`) then setenv PAGER less endif # We don't want colors in emacs shell mode if(${?EMACS}) then set SHELLCOLOR=0 endif # Midc gets confused by our fancy xterm prompt, so disable prompt for it if(${?MC_CONTROL_FILE}) then set XTERM_TITLE_PROMPT=0 endif ##################################################################### ## Default shell setup ##################################################################### # Set default prompt set prompt="${DEFAULT_PROMPT}" # Make double tab show complete list set autolist=ambiguous # I want English program text setenv LC_MESSAGES en_US.ISO8859-1 # Long history set history = 1000 if("$USER" == "root") then # Don't autologout for root screen if(!("$TERM" == "screen" && "$LOGNAME" != "root")) then # We don't want root logins around # Autolock after 1H and logout after 4H set autologout=(240 60) endif # Sometimes root does not get user xauth info.. for "steal" it if(-r "/home/$LOGNAME/.Xauthority") then # But dont do it if XAUTHORITY var is set since that may mean that # root will take ovnership of a user xauth file if(! ${?XAUTHORITY}) then if(-x `which xauth`) then xauth merge /home/$LOGNAME/.Xauthority endif endif endif # Alias to reload FreeBSD firewall rules more safely remote (no output) if("$OSTYPE" == "FreeBSD") then alias reloadfw "echo -n 'Starting fw reload at : ' > ${FW_OUT_FILE} && date >> ${FW_OUT_FILE} && sh /etc/rc.firewall >>& ${FW_OUT_FILE}; less ${FW_OUT_FILE}" endif endif # Give warning for rm * set rmstar # I want't CTRL-D for logout unset ignoreeof # We never use RSH for CVS, always ssh setenv CVS_RSH ssh # Enable or disable tcsh color support if(${SHELLCOLOR}) then set color=ls-F else unset color unsetenv CLICOLOR endif # Enable FreeBSD ls color support if wanted if(${SHELLCOLOR} && "$OSTYPE" == "FreeBSD") then # Colors in ls setenv CLICOLOR endif # Enable colors in GNU ls if(${SHELLCOLOR} && "$OSTYPE" == "linux") then alias ls "ls --color=auto" endif ##################################################################### ## Misc environment stuff ##################################################################### setenv P4CONFIG .p4config setenv FTP_PASSIVE_MODE YES setenv PATH "${HOME}/bin:${PATH}:${HOME}/scripts" ##################################################################### ## Misc extra completions ##################################################################### # Complete port names complete portupgrade 'n@*@D:/var/db/pkg/@' complete pkg_delete 'n@*@D:/var/db/pkg/@' # For sudo complete commands like they were the first command, but # portupgrade is special. complete sudo 'p/1/c/' 'n@portupgrade@D:/var/db/pkg/@' 'n@pkg_delete@D:/var/db/pkg/@' # Complete sysctl variabels complete sysctl 'n/*/`sysctl -Na`/' # From http://hea-www.harvard.edu/~fine/Tech/tcsh.html # directories complete cd 'C/*/d/' complete rmdir 'C/*/d/' complete lsd 'C/*/d/' # variables complete unset 'p/1/s/' complete set 'p/1/s/' # environment variables complete unsetenv 'p/1/e/' complete setenv 'p/1/e/' # aliases complete alias 'p/1/a/' complete unalias 'p/1/a/' # signal names # also note that the initial - can be created with the first completion # but without appending a space (note the extra slash with no # append character specified) complete kill 'c/-/S/' 'p/1/(-)//' complete killall 'c/-/S/' 'p/1/(-)//' '' # of course, this completes with all current completions complete uncomplete 'p/*/X/' # It's most likely that we want to make a completion for a command complete complete 'p/1/c/' # groups complete chgrp 'p/1/g/' # users complete chown 'p/1/u/' # use available commands as arguments for which, where, and man complete which 'p/1/c/' complete where 'p/1/c/' complete man 'p/1/c/' ##################################################################### ## Misc aliases ##################################################################### alias ls "ls-F" alias ll "ls -l" alias la "ls -loa" alias lh "la -lh" alias cp "cp -i" alias mv "mv -i" alias m "make" alias fullsync "sync && sync && sync && sync && sync && sync && sync" alias ec "emacsclient -n" alias qcvsupd "cvs update | grep -Ev '^\?'" alias mkcvsfilelist "cvs -nfq update | grep -Ev '^[\?U]' | sed -e 's%^[AM] %%g' | tr '\n' ' ' && echo" # I don't want mouse i mc alias midc "midc -d" alias mc "mc -d" alias dkwhois "whois -h whois.dk-hostmaster.dk" alias ripewhois "whois -h whois.ripe.net" alias bindversion "nslookup -class=chaos -q=txt version.bind" alias manf "groff -Wall -Tascii -te -mandoc \!^ | less" alias manps "groff -Wall -Tps -te -mandoc" alias manl "groff -Wall -Tascii -mdoc \!^ > /dev/null" alias fetchpr 'scp freefall:/home/gnats/\!^ .' alias setdocdir "setenv DOCDIR $HOME/public_html/doc" alias freebsd-cvs2cl 'cvs2cl -r -b -t -S --utc --no-wrap' alias sa-test "spamassassin \!^ | egrep -A3 ^X-Spam-" alias wgetm "wget --no-parent -mk --wait=2 --random-wait" alias dkaspell 'aspell -dda' alias real-mozilla /usr/X11R6/lib/mozilla/mozilla alias etags-upd "rm -f TAGS ; find -E . -regex '.*\.(c|h|cpp)' | xargs etags -a -o TAGS" alias p4diff "p4 diff -du" alias convert90 "mv -n \!^ \!^.orig && convert -rotate 90 \!^.orig \!^" alias convert270 "mv -n \!^ \!^.orig && convert -rotate 270 \!^.orig \!^" ##################################################################### ## Misc term depended stuff ##################################################################### # Eterm isn't a std. known term... if("${TERM}" == "Eterm") then setenv TERM "xterm-color" endif # Workaround for odd rxvt bug where 'H' in sh erease chars if(${?COLORTERM}) then if("${COLORTERM}" == "rxvt-xpm" && "${OSTYPE}" == "FreeBSD") then stty erase2 ^H endif endif switch ("$TERM") case "xterm*": case "rxvt": # Prompt that also changes xterm title if wanted if(${XTERM_TITLE_PROMPT}) then set prompt="%{\033]0;${XTERM_TITLE}\007%}${DEFAULT_PROMPT}" endif # Make nice title when using pine if(-x `which xtitle` && -x `which pine`) then alias pine "xtitle 'pine (${MAIN_EMAIL_ADDR})'; `which pine`" endif # Guess if we have xterm-color support from OS type if("$OSTYPE" == "linux" || "$OSTYPE" == "FreeBSD") then setenv TERM xterm-color endif if("$OSTYPE" == "hpux" || "$OSTYPE" == "osf1" || "$OSTYPE" == "solaris") then setenv TERM xterm endif # Check if local system has termcap if(-r /etc/termcap) then # Check if termcap has xterm-color support if(! -z `grep "xterm-color" /etc/termcap`) then setenv TERM xterm-color else setenv TERM xterm endif # End has xterm-color check endif # End /etc/termcap exists # Special screen term hack - screen doesn't like TERM xterm alias screen 'setenv TERM_TMP ${TERM}; setenv TERM vt100; \screen' if( -x `which xtitle` ) then alias "mutt" "xtitle mutt - $MAIN_EMAIL_ADDR; `which mutt`" endif breaksw endsw ##################################################################### ## OS specific stuff ##################################################################### if("$OSTYPE" == "FreeBSD") then # midc concurrent shell doesn't work properly under FreeBSD - disable it alias midc "midc -du" endif ##################################################################### ## DIKU specific stuff ##################################################################### if(${?DIKUARCH}) then if(`echo $USER | cut -b 1-2` == "di") then set DIKU_DI_ACCOUNT=1 endif # Enable DIKUNIX setenv PATH ${PATH}:/usr/local/dikunix/bin setenv MANPATH ${MANPATH}:/usr/local/dikunix/man setenv LD_LIBRARY_PATH /usr/local/dikunix/lib:${LD_LIBRARY_PATH} # Use DIKU proxy's setenv http_proxy "http://proxy.diku.dk:8080/" setenv ftp_proxy "http://proxy.diku.dk:8080/" # Kernel stuff : alias lk cat /vol/www/students/andresen/index.txt alias dircode "cd ~/dat1f/k2/kode/" alias dirrap "cd ~/dat1f/k2/rapport" # CVS if(${?DIKU_DI_ACCOUNT}) then setenv CVS_RSH "${HOME}/bin/shell/cvs_remote.sh" endif # We don't want to run in to nedit unsetenv VISUAL # DIKU arch specific stuff switch ("$DIKUARCH") case "hppa1.1-hp-hpux10.20": # ask.diku.dk (and other hp's?) don't have ping in default path alias ping /usr/sbin/ping breaksw endsw # Distsys stuff setenv MPI_HOME "/opt/scali" setenv PATH "${PATH}:${MPI_HOME}/bin:${MPI_HOME}/contrib/pbs/bin" setenv LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:${MPI_HOME}/lib" setenv MANPATH "${MANPATH}:${MPI_HOME}/contrib/pbs/man" # Dat2a #setenv LEDAROOT /usr/local/projects/disk02/algorithm/LEDA-4.3 #setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${LEDAROOT} endif ##################################################################### ## Keychain ##################################################################### set KEYCHAIN="" if(-x "/usr/local/bin/keychain") then set KEYCHAIN="/usr/local/bin/keychain" endif if(-x `which keychain`) then set KEYCHAIN=`which keychain` endif if(-x "${HOME}/bin/shell/keychain") then set KEYCHAIN="${HOME}/bin/shell/keychain" endif if(${USE_KEYCHAIN} && ${?KEYCHAIN} && -x "${KEYCHAIN}") then if(${KEYCHAIN_QUIET}) then ${KEYCHAIN} --nocolor > /dev/null else ${KEYCHAIN} --nocolor endif if(-r "${KEYCHAIN_SH_FLE}") then source ${KEYCHAIN_SH_FLE} endif endif ##################################################################### ## Custom additions to tcshrc ##################################################################### # Read custom .tcshrc if(-r "${HOME}/.tcshrc.local") then source "${HOME}/.tcshrc.local" endif