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

Re: option to show file:line everytime echo is called?



On Fri, 13 Jan 2017, Daniel Shahaf wrote:

> % echo() { set -x; builtin echo "$@" }

That's more output than he wanted.

  echo() { print -n "$funcfiletrace> "; builtin echo "$@" }

is probably more like it.

Similarly

  typeset -AgH whence_my_alias
  alias() {
    emulate -L zsh
    local opts
    zparseopts -D -a opts L g m r s
    if [[ -z $opts[-m] && $1 = *=* ]] && whence_my_alias[${1%=*}]=$functrace
    builtin alias $opts $*
  }
  whence() {
    local whence="$(builtin whence "$@")"
    case "$whence" in
    (* is an alias for *)
       local from="${whence_my_alias[${whence%% *}]}"
       print -r -- "$whence" ${from:+from} "$from"
       ;;
    (*) print -r -- "$whence";;
    esac
  }

Some edge cases possibly not caught.



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