Search code examples
linuxshelltcsh

Automate ls command after every cd command in tcsh


I change the directory by giving cd (dir_path). When I give this, it also wants to display the contents in the directory. Say like if we type ls after going to that directory. Basically the two commands should execute together cd (dir_path) and a ls in that path only by giving the cd (dir_path) command.

How to do that in tcsh?


Solution

  • I think the simpliest method is to use cwdcmd:

    alias cwdcmd ls
    

    Can be put it into ~/.tcshrc.

    See man tcsh:

    Special aliases

    ....

    cwdcmd

    Runs after every change of working directory.