forked from Worldie-com/pen.el
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclean-term-capture
More file actions
executable file
·39 lines (33 loc) · 926 Bytes
/
clean-term-capture
File metadata and controls
executable file
·39 lines (33 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
export TTY
while [ $# -gt 0 ]; do opt="$1"; case "$opt" in
"") { shift; }; ;;
-rmtm) {
rm_tmux=y
shift
}
;;
*) break;
esac; done
(
if test "$rm_tmux" = "y"; then
sed -z 's/\n\[ .*//'
else
cat
fi
) | sed -e 's/[▒▄]/ /g' \
-e 's/[┌┐┘└│├─┤┬┴┼╰╯╭╮🟠⃘]/ /g' \
-e 's/ ·\+$//g' |
sed -e ':loop' -e 's/^\( *\) · /\1 /g' -e 't loop' |
sed -e 's/\( ·\)\+ *$//g' ` # jupyter tui ` \
-e 's/\( ·\)\+ *$/ /g' ` # jupyter tui ` \
-e 's/\s\+$//g' ` # remove trailing whitespace ` \
-e '/^\~$/d' ` # vim ` |
sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' |
sed "s/^\\s\\+$//" | sed ':a;N;$!ba;s/\n\n\+/\n\n/g'
# -e 's/^ \(· \)\+//g' ` # jupyter tui ` \
# -e 's/^ \(· \)\+/ /g' ` # jupyter tui ` \
# piping into cat here breaks it. It creates a race
# condition with the outer cat, or something. Do not do
# this.
# | cat