2

I cannot seem to find an answer to this question. In my .bash_profile I have this line:

cd() { builtin cd "$@"; ll; }

which executes ll every time I change directories. I would like this functionality in tcsh as well, but I have not the foggiest of how to add this to my .cshrc file. They yelled at me for posting this in stackoverflow, and sent me here.

1 Answer 1

2

The manual page for tcsh is the place to start, because it gives an example which can be adapted:

For example, alias print 'pr !* | lpr'' defines a ``command'' (`print') which pr(1)s its arguments to the line printer.

Thus:

alias cd 'cd \!* ; ls'

This happens to work (see the section Alias substitution) because tcsh detects the use of cd in the alias and stops recurring:

Alias substitution is repeated until the first word of the command has no alias. If an alias substitution does not change the first word (as in the previous example) it is flagged to prevent a loop. Other loops are detected and cause an error.

1
  • Awesome. Thank you!! Glad it's not a builtin function, making this so much easier to do.
    – AustinM
    Commented Nov 21, 2015 at 0:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .