Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: prefix all commands?



River Tarnell sent me the following 0.8K:

> i would like to write a script which can prefix all commands with "pfexec ".  
> for example, if the user runs "ls", the shell should actually run "pfexec 
> ls".  similarly, "a | grep b" should become "pfexec a | pfexec grep b".
> 
> is there any way to do this?

I do something like this to interactively sandwich a command to run it
in gdb: 

   run-in-gdb() {
      # This function is ZLE widget that runs the current command in gdb.
      # It commits the current, unaltered command line to history, insets
      # its words in a gdb command, and runs it.
      print -s ${(z)BUFFER}
      BUFFER="gdb -x =(print run) --args $BUFFER"
      zle accept-line
   }
   zle -N run-in-gdb
   bindkey "^X^G" run-in-gdb

I just type the command normally, hit <Control-X><Control-G>, and gdb
takes the program and runs it.  You could do something similar but
insert pfexec instead.  But perhaps you're looking for something more
pervasive?

-- 
Chris Johnson
cjohnson@xxxxxxxxxx
http://www.cs.utk.edu/~cjohnson



Messages sorted by: Reverse Date, Date, Thread, Author