Skip to content

Commit

Permalink
feat(zsh): save zsh xtrace output to file
Browse files Browse the repository at this point in the history
Signed-off-by: vladislav doster <10052309+vladdoster@users.noreply.github.com>
  • Loading branch information
vladdoster authored Oct 12, 2024
1 parent d31b2c3 commit 9c98570
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions zsh/.config/zsh/functions/zsh-xtrace
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#autoload
#
# zsh-xtrace
#

__zsh-xtrace_usage () {
print -- 'Usage: zsh-xtrace [options] [arguments...]'
print -- 'Options:'
print -- ' -d, --debug turn on execution tracing'
print -- ' -h, --help show list of command-line options'
}

setopt localoptions extended_glob
zmodload zsh/zutil || return 1

local base debug help
builtin zparseopts -D -E -F -K \
d=debug -debug=debug \
h=help -help=help \
|| return 1

if (( $#help )); then
__zsh-xtrace_usage
return 0
fi

if (( $#debug )); then
setopt xtrace
fi

local -a arguments=(${(q+)^@})

zsh --norcs -lxvc "${@}; return" 2>&1 | ts -i "%.s" | ansifilter > zsh_start.log
print -l -- "${#arguments} args" ${(@)arguments}

# vim: set expandtab filetype=zsh shiftwidth=2 softtabstop=2 tabstop=2:

0 comments on commit 9c98570

Please sign in to comment.