csh sensible defaults

On FreeBSD (and possibly others) the csh is the default login shell for root or default users. I always try to avoid it and use bash. However, sometimes it's not possible or dangerous to install bash (inside a jail for example).

So I decided to check if it is possible to configure csh in a way to make it less annoying. I read the docs, tried many different options and here is the result.

That's not much but helps digging around a system using csh. With this config you'll get:

# sensible defaults for CSH 
alias  h     history 25
alias  j     jobs -l
alias  la    ls -a
alias  lf    ls -FA
alias  ll    ls -lA
alias  l     ls -laF
alias  lt    ls -ltr
alias  md    mkdir -p
alias  ..    cd ..
alias  ...   cd ../..
alias  ....  cd ../../../
alias  vi    nvi
alias  vim   nvi

# A righteous umask
umask 22

# environment config
set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin $HOME/bin) setenv EDITOR vi setenv PAGER more setenv BLOCKSIZE K

# if interactive, configure further
if ($?prompt) then # interactive prompt
 
set prompt = "%N@%m:%~ %# “ set promptchars = ”%#"

# history config
 
set history = 5000 set savehist = 5000

# complete case-insensitive
set complete = enhanced # print possible completions if more than 1 match
 
set autolist = ambiguous # enable filename completion
 
set filec # shut up
 
set nobeep # enable redirect protections
 
set noclobber # forbid rm *
 
set rmstar # mail?
 
set mail = (/var/mail/$USER)

# convenience bindkeys, similar to emacs or inputrc
 
# ALT-LEFT
 
bindkey "^[^[[D" backward-word # ALT-RIGHT
 
bindkey "^[^[[C" forward-word # ALT-UP + HOME
 
bindkey "^[^[[A" beginning-of-line # ALT-DOWN + POS1
 
bindkey "^[^[[B" end-of-line # CTRL-R (like bash), then type
 
bindkey "^R" i-search-back # SHIFT-TAB cycles through possible completions, let go if good
 
bindkey "^[[Z" complete-word-fwd endif

#source

↷ 13.07.2017