0

In tcsh, how to set bind-key for general command like cd or ps ?

I was trying bindkey "^G" "cd ../../" I get error Bad Command name: cd

I have looked at few online example. Its working when I want to do something, history search forward or end of line. But I want to do it for some other common command which I execute thousands of time in given day. e.g I use CD or ps command very often. I wanted to set bindkey for such commands ?

1 Answers1

1

You can use the -c flag when setting bindkeys for external commands. For instance: bindkey -c "^]^d" "ls /" will bind Ctrl+]+d to spit out the contents of the root directory.

In your case:

 bindkey -c "^G" 'cd ../../'

One caveat here is that your shell prompt may not update upon execution via the bindkey. So you will have traversed your two parent directories, but your shell prompt may still indicated that you are sitting in the directory from which you used the bindkey, even though you aren't.

JNevill
  • 46,980
  • 4
  • 38
  • 63