Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
De-script (Re: Vanishing files ?)
- X-seq: zsh-users 10345
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: De-script (Re: Vanishing files ?)
- Date: Mon, 29 May 2006 11:16:01 -0700
- In-reply-to: <20060529075722.GA28846@xxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20060528.172405.74744323.Meino.Cramer@xxxxxx> <060528113200.ZM31855@xxxxxxxxxxxxxxxxxxxxxx> <20060529075722.GA28846@xxxxxx>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author