Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Intercepting commands before they're run
- X-seq: zsh-users 3022
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Oliver Kiddle <opk@xxxxxxxxxxxxx>, zsh-users@xxxxxxxxxxxxxx
- Subject: Re: Intercepting commands before they're run
- Date: Thu, 13 Apr 2000 16:21:20 +0000
- In-reply-to: <38F5B637.5D5BE0F1@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <38F5B637.5D5BE0F1@xxxxxxxxxxxxx>
On Apr 13, 12:57pm, Oliver Kiddle wrote:
} Subject: Intercepting commands before they're run
}
} I've just been experimenting with the MH mail system to see if it will
} do what I hope. In mush I can ...
Sigh.  It used to be that most people switched from MH to mush because
mush was so much faster.
} ... just type a message number to see a
} message so I tried to think of a way to persuade zsh to do this.
} 
} preexec() {
}   [[ $1 = <-> ]] && show $1
} }
Try (assuming you have FUNCTION_ARGZERO set):
    preexec() {
      [[ $1 = <-> ]] && function $1 { show $0 ; unfunction $0 }
    }
The more general case is of course
    preexec() {
      setopt localoptions extendedglob
      local cmd
      cmd=($=1)
      case $cmd[1] in
      (<->) function $1 { show $0 ; unfunction $0 };;
      (d(<->[-,])#<->) function $1 { delete ${0#d} ; unfunction $0 };;
      # ... do the whole mush command set ...
      (...#) eval function $1 \{ cd ..${${1#..}:gs@.@/..}\; unfunction $1 \};;
      # ... any other mappings you want go here ...
      (*) ;;
      esac
    }
} [...] maybe we should let preexec return an exit code to say the command
} should not be run [...]
I think I suggested that at one point, but I don't recall whether there
was any discussion.
-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author