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

Re: What was the reason for history -D not reporting runtimes?



On 11/24/06, Nikolai Weibull <now@xxxxxxxx> wrote:
I have a vague memory of asking this question earlier, but I couldn't
find it in any of the archives and not in my own mail-archive either,
so here it goes (again, probably):

Why does history -D not report times correctly, only giving 0:00?

Ah, I found the culprit.  I use Bart's version of preexec for setting
the title inside screen.  It seems that using the z expansion flag in
cmd=${(z)1}) messes up the time-tracking code somehow.

This is what I have

_set_title () {
 [[ $LOCKTITLE == 1 ]] && return
 case $TERM in
   (screen*)
     print -nR $'\ek'${1[1,18]}$'\e\\' ;;
 esac
 return 0
}

precmd () {
 _set_title zsh
}

preexec () {
 local -a cmd

 cmd=(${(z)1})
 case $cmd[1] in
   (fg)
     if (( $#cmd == 1 )); then
       cmd=(builtin jobs -l %+)
     else
       cmd=(builtin jobs -l ${(Q)cmd[2]})
     fi ;;
   (r)
     cmd=($(builtin history -n -1))
     _set_title $cmd[1]:t
     return ;;
   (%*)
     cmd=(builtin jobs -l ${(Q)cmd[1]}) ;;
   (exec)
     shift cmd ;&
   (*)
     _set_title $cmd[1]:t
     return ;;
 esac

 local -A jt

 jt=(${(kv)jobtexts})

 $cmd >>(read num rest
         cmd=(${(z)${(e):-\$jt$num}})
         _set_title $cmd[1]:t) 2>/dev/null
}

I'm unable to determine why this breaks.  If I substitute ${=1} for
the expansion, it still breaks as soon as it gets to printing in
_set_title.

 nikolai



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