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:

  • completion similar to bash
  • right/lift jumping by words using CTRL-left and CTRL-right
  • CTRL-up goto beginning of line, CTRL-down goto end of line
  • history search using CTRL-R
  • some sensible aliases
  • a meaningful prompt
# 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

13.07.2017 19:24 CC0 freebsd shell Source

Similar posts

Null Comment zu csh sensible defaults



Add Comment:
Aus welchem Land kommen Sie?
Land*:
Your comment will only displayed publicly after my approval! Fields marked with * are mandatory.
If you include an email address, it will be deleted automatically after one month. Nothing else will be stored.