From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: De-script (Re: Vanishing files ?)
Date: Mon, 29 May 2006 11:16:01 -0700 [thread overview]
Message-ID: <060529111601.ZM1755@torch.brasslantern.com> (raw)
In-Reply-To: <20060529075722.GA28846@sci.fi>
On May 29, 10:57am, Anssi Saari wrote:
}
} > } By the way: Does anyone know a trick how to remove _all_
} > } Escape-Sequences from a script generated by the command "script" ...
} >
} > sed "s/[^"$'\t '"-~]//g"
}
} That doesn't really work for escape sequences now does it?
Ah, I see, I misinterpreted the original question. In order to strip
entire terminal-control strings, you have to know what they are; which
means in effect that you have to (a) read the termcap/terminfo database
and (b) know the value of $TERM at the time the typescript was created.
You could create something to do this using the perl Term::Cap and/or
Term::Info modules, or in zsh with zsh/termcap and zsh/terminfo. The
tricky bit is knowing which escapes use numeric counts or positions, so
you can accept arbitrary digits at those locations.
E.g. this is an UNTESTED example of what might work in zsh:
function descript {
( # Subshell for parent terminal sanity
emulate -R zsh
typeset -A tpat
TERM=${1:-$TERM}
# Replace terminfo + echoti with termcap + echotc as needed
for key in ${(k)terminfo}
do
[[ $terminfo[$key] == (yes|no) ]] && continue
# Replace programmable digits with the <-> pattern.
# If you have a 1000x1000 or larger terminal, I give up.
tpat[$key]=${${(q)"$(echoti $key 998 998)"//$'\0'/}//99[89]/<->}
# Debugging output:
# print -u2 -R $key = ${(V)tpat[$key]}
done
pat=${(j:|:)tpat}
# Run through "col" first to handle simple cursor movement
col -bp | while read -r line
do
print -R -- ${line//(${~pat})/}
done
)
}
Usage is e.g.:
descript color-xterm < typescript
Also realize that after you strip those, the result is no longer going
to resemble what was visible on the screen during the creation of the
typescript.
next prev parent reply other threads:[~2006-05-29 18:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-28 15:24 Vanishing files ? Meino Christian Cramer
2006-05-28 18:32 ` Bart Schaefer
2006-05-28 18:38 ` Meino Christian Cramer
2006-05-28 23:24 ` Bart Schaefer
2006-05-29 2:38 ` Meino Christian Cramer
2006-05-29 7:57 ` Anssi Saari
2006-05-29 15:32 ` Peter Stephenson
2006-05-29 17:51 ` Paul Lew
2006-05-29 18:16 ` Bart Schaefer [this message]
2006-05-28 18:37 ` DervishD
2006-05-28 18:44 ` Meino Christian Cramer
2006-05-29 6:11 ` DervishD
2006-05-29 8:56 ` Meino Christian Cramer
2006-05-29 8:58 ` DervishD
2006-05-30 21:59 ` Tobias Gruetzmacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=060529111601.ZM1755@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).