zsh: Bind a key to an arbitrary function?

zsh: Bind a key to an arbitrary function?

Post by Tim Gilbe » Mon, 31 Jul 1995 04:00:00



Hi.  Is there any way to bind a key to an arbitrary function in
zsh?  I am finding myself missing tcsh's run-fg-editor command
(which I bound to ^Z when I was running tcsh).  I have read TFM,
so I know I can do something like:

bindkey -s ^Z "fg\n"

So that whenever I type ^Z it will be like typing in "fg", but
this is unsatisfactory for a variety of reasons (eg, it appears
in the history buffer, and I can't type it in the middle of a
command).

BTW, I am running zsh 2.5.03.  Any help would be appreciated...
Thanks.                                                 -- Tim
--

 
 
 

zsh: Bind a key to an arbitrary function?

Post by Chip Benowit » Mon, 31 Jul 1995 04:00:00



> Hi.  Is there any way to bind a key to an arbitrary function in
> zsh?  I am finding myself missing tcsh's run-fg-editor command
> (which I bound to ^Z when I was running tcsh).  I have read TFM,
> so I know I can do something like:

> bindkey -s ^Z "fg\n"

> So that whenever I type ^Z it will be like typing in "fg", but
> this is unsatisfactory for a variety of reasons (eg, it appears
> in the history buffer, and I can't type it in the middle of a
> command).

> BTW, I am running zsh 2.5.03.  Any help would be appreciated...
> Thanks.                                                 -- Tim

Well, it's not a great method, but you could pick use stty to bind ^z
to something you are not planning to need, and then use trap to have
that run fg... (use kill -list to see what all the traps are)

Chip

 
 
 

1. HDI: call an arbitrary function with an arbitrary number of arguments (and possibly arbitrary types)

If only this were lisp where the world is simple...  I'm not too happy
about http://www.eskimo.com/~scs/C-faq/q15.12.html , is there a
solution for Linux/GCC?  How about C++?

I figured out how to call an arbitrary function (here "ioctl") with
known arguments;

      int fd = open("/dev/cdrom", O_RDONLY);
      void *handle = dlopen("/lib/libc.so", RTLD_LAZY);
      int (*function)() = dlsym(handle, "ioctl");
      (*function)(fd, CDROMCLOSETRAY);  // whee
      dlclose(handle);

For a pseudo-arbitrary number of arguments, I could have a switch
statement that handles the cases for 0, 1, 2, 3, x arguments but how
lame would that be?

/me suddenly obsessed with partially implementing WinNT's
    "rundll32.exe" in Linux.

-N.
--
http://www.cs.mcgill.ca/~navindra/editors/

2. Wanted -- Used (cheap) RS6000/320

3. tcsh binding of function keys

4. PPP help...

5. bind keys to a function

6. PROBLEM- Segmentation fault occurs when dd'ing entire drive (9.x GB) to a vfat partition.

7. CDE function key 1 binding

8. HSM & Backup software for STK4400 needed

9. binding function keys in tcsh

10. How do I bind a function key in Bash?

11. binding a function key in xterm

12. Emacs Function Key Binding on RS/6000

13. Binding function keys to front/copy etc...