# Pre OR post command in CSH HOW?



## miniqq (Mar 8, 2010)

In sh, bash, ksh, I can use `$ trap` with the signal DEBUG to get a hook of running command. like:

```
my_debug_func () {
xxx
...
}

trap my_debug_func DEBUG
```
put them in the login shell profile and can get my functions or script run before executing other shell command enter behind the prompt.

*How to do that in csh ? csh has no "trap"?!*


----------



## achix (Mar 8, 2010)

Your best bet would be `# onintr [-|label]`, but i guess its far from what you were looking for, cause onintr seems to apply to all interrupts, without being able to specify only the ones you want.


----------



## miniqq (Mar 9, 2010)

Yes, I checked out "`$ onintr`" , it doesn't what i want.

Is there another way ? without using SIGNAL ?
like those functions 

```
preexec()
precmd()
```
in Zsh .


----------



## miniqq (Mar 9, 2010)

Oh , Yeah, I found Csh has a "precmd" too !
But base on the action of "precmd" , it should be called "postcmd" !


----------

