Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: time command with shell builtins
- X-seq: zsh-users 28888
- From: Dominik Vogt <dominik.vogt@xxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: time command with shell builtins
- Date: Thu, 2 Feb 2023 19:10:26 +0100
- Archived-at: <https://zsh.org/users/28888>
- In-reply-to: <Y9Ko+7GqksX+LKww@localhost>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: Zsh Users <zsh-users@xxxxxxx>
- References: <CAN=4vMqSxEr-K1xg+fGc9kh2qfiZ31fy7hoDBRNHXXF6pH8eEg@mail.gmail.com> <Y86ZkYooJ9Kf4xCE@localhost> <CAHYJk3QD8NbCqt0LdXshiVf6W3GQLnDzo6-1mj0qCJOTkHFGRA@mail.gmail.com> <Y87Ws8PrZY8W3Oao@localhost> <CAHYJk3Tu5POCU08-g1dr2p284p89Xak5XjLSV6J8gWdQnOXDeA@mail.gmail.com> <Y8+3h5OXqtpkyewM@localhost> <Y9BlzD/hb4bwHAmb@localhost> <CAH+w=7Z3Srhc02WEmBv_m6YiGUm4mPw2oxNqfTAcm6kqm+GE=w@mail.gmail.com> <Y9B7A8dWLiZNXKfW@localhost> <Y9Ko+7GqksX+LKww@localhost>
- Reply-to: dominik.vogt@xxxxxx
- Ui-outboundreport: notjunk:1;M01:P0:gdW95KDbElA=;DG8nK8oP7YpMSOMV9XHkrfFtkwv S5DZ4kHfGVSghNKTpSwbHHVoev9QTRdz18zQ5JOYcHWnSDd51Ksu8TcwtYyRlAfg0nWU9hSFw QVXftnCjPaAOQ5NpZgRpBbqEqxetnw8b/j2mb6BwsOJSVp5Ww/dJjCSthRd26ZIMr8k0eVtIo W09LphQ5vSKk8WOWIhVkWMt5jUNjl635EcF2TmQJqtu0JmoyymVKeHnRk0Ym7USLqfPpTgpIn Gm/UjKdGjQJWQ0Lud5/JcRX5rf4piHDL5cGp6Cq9C8P2qYr1bzoS05drK9bL/s5ykeP5zWSYl s6yGuCWrQIvoxZSWVKg4xzVS9IGVrtyoTyabuH0dj2yMyGOT/l07PlRpT/inIOKDH4yTr7Ue3 pc9pZcL7NV/2anwnp4uAa0STTJdbviYbYP1tD10w88X7fVTCkIE6FUEIt6KRfKXX+iNJTYBG6 E7EqAvGBDnk2zkal+DUkNVUcIlCCH+WsSCCZFKbn2Xw7iSM5W23pyxZRR7p/Ko2lRykXjjh0+ sA544dd8e8niJJ467vWGWeom29+bk6NTFMGvpGuAe6prEFglTzkJGtZ6EINIcENLI/+LzjH53 /GJT6zGyc+vhZ9B4wgm4C2/rFsWBso6jffxwdhb7BCTh5mFeiYQCuvK87AYtB0ZhhBCBHwA/W 8YIQdR1omccuay2ovrrPHdRXwJtqLb4dis1V8lWJAOCUavgeJPCvCLfa4TVasHhy04Ez3vxJ4 oTIB+3rPc23hl0Qm6wvHnsiCXhkJn/UXqWG/t7lF55MILdG5DvL+v4QCgQAoB7qELnpLKGok3 bmnhVXQ06QaoC0V5wnluKt4NAcEIH2igKFdTnt2KsfPaxScpTz8nMMkLRD++xqZGpP/Wr24kp 1k7wOOumThyi3CWorMhRAxsvmEFuvr72bOqC9z9Y3IFe0Rwf1+AH5+I9rMYZMOcPEX/8A+ZIs ikBGJKzn+ciSrA88JS95ulZkkeM=
On Thu, Jan 26, 2023 at 05:23:23PM +0100, Dominik Vogt wrote:
> On Wed, Jan 25, 2023 at 01:42:43AM +0100, Dominik Vogt wrote:
> > On Tue, Jan 24, 2023 at 03:36:51PM -0800, Bart Schaefer wrote:
> > > On Tue, Jan 24, 2023 at 3:14 PM Dominik Vogt <dominik.vogt@xxxxxx> wrote:
> > > >
> > > > As far as I understand there's no reliable access to
> > > > which command is being executed in preexec.
> > >
> > > There's reliable access to what the user typed and to what that
> > > expands to after alias replacement. What else would you be looking
> > > for?
> >
> > Well, it's more or less "if whatever is being executed is
> > interactive, I'm not interested in the time". This is impossible
> > to guess from the command name, except in some manually specified
> > cases. Maye a simple "if command is one of emacs, vi, vim, sleep,
> > mutt, visudo, bash, zsh, sh" is good enough. Or I just get used to
> > having unnecessary information in the prompt.
>
> Is there a more elegant way to chek if the command is in a
> blacklist than this one?
>
> -- snip --
> _zsh_recordtime_skip_list=( emacs vi vim zsh bash sh viduso mutt sleep xemacs )
> function preexec_recordtime() {
> if [[ -z "${1:|_zsh_recordtime_skip_list}" ]]; then
> psvar[2]=''
> ...
> }
> -- snip --
Well, is there a way to detect inside preexec() wether a command
is handled by the shell or some external binary? The usual
REPORTTIME mechanism works for external commands, so using
preexec/precmd to print run time for shell builtins is good enough.
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
Messages sorted by:
Reverse Date,
Date,
Thread,
Author