Ivan Tomica

Fix delete key in CSH or TCSH

CSH is the default shell for root user on FreeBSD system. Basic usage is pretty much the same as any other shell like bash, zsh, fish or whatever. Until you try to execute some bash specific for loops, or attempt to use Delete key. Whaaaat? – Yes, apparently delete doesn’t give the correct character in csh and just prints ~. I don’t know if that’s xterm (or xterm compatible) terminal thing or just a csh thing but it doesn’t matter.

Here’s how to solve it:

  1. Open up ~/.cshrc in your favorite text editor
  2. Within your prompt section (if ($?prompt) then) add following block (or fill in the needed bindkey if you already have that section):
            if ( $?tcsh ) then
                    bindkey "\e[3~" delete-char
  3. Save the file and run:
    source ~/.cshrc

Voila, it should work!

Tagged in:, ,
Sysadmin on the everlasting journey of learning. Always in search for an opportunity to prove myself and to learn something new. My addiction is learning and my main goal is to excel in every aspect of Linux/Unix system administration.


Leave a Reply

Your email address will not be published. Required fields are marked *