memory-leaks

Still reachable: lots of words in many pages.
git clone https://git.kevinlegouguec.net/memory-leaks
Log | Files | Refs | README | LICENSE

commit 850e2513ea4995703d0aaaf5f6db8649dfa0e047
parent d006e6b24ae86783c9a6d467a111e7a917672bef
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Sun, 12 Apr 2020 16:31:26 +0200

Note down wishlist for shell.el

It's annoying to have to spell out "apt-get", and I don't want to
configure APT not to use the fancy progress bar because I happen to
like it.

Alternative approach: https://oremacs.com/2019/03/24/shell-apt/

Diffstat:
Mitches/emacs/interpreters.org | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+), 0 deletions(-)

diff --git a/itches/emacs/interpreters.org b/itches/emacs/interpreters.org @@ -4,6 +4,80 @@ ** Use Bash completions. E.g. in most terminals, typing ~ls TAB~ in a folder with a single file expands to ~ls that-file~. +** Handle DECSC, DECRC, CUU, ED, HVP and DECSTBM console codes. +Used for APT's "Dpkg::Progress-Fancy" option, enabled by default with +the high-level apt(8) command. Silly script emulating what APT does: +#+begin_src bash +#!/bin/bash + +set -eu + +if ! test "${LINES:-}" -a "${COLUMNS:-}" +then + echo Please export LINES and COLUMNS. + exit 1 +fi + +# Adapted from apt/apt-pkg/install-progress.cc. + +backup=$'\e7' # DECSC: backup cursor position. +restore=$'\e8' # DECRC: restore cursor position. + +setup () +{ + echo -n ${backup} + # DECSTBM: restrict scrolling below command, and above progress + # bar. Side-effect: move the cursor to position 1:1, + # hence the backup/restore. + echo -n $'\e[0;'$((LINES-1))'r' + echo -n ${restore} +} + +teardown () +{ + # ED: clear everything from current position to end of screen. + # Dixit Michael Vogt: "sledgehammer". + echo -n $'\e[J' +} + +# APT surrounds this setup phase with \n and \e[1A (CUU). I don't +# know why; the comments say that this is to "avoid visual glitch when +# the screen area shrinks by one row". No further explanation is +# given in commit messages. +setup + +for ((i=1;i<COLUMNS-1;i++)) +do + if ! ((i%10)) + then + echo "installing stuff" + fi + + echo -n ${backup} + + # HVP: move cursor to last line, first column. + echo -n $'\e['${LINES}';1f' + + # Draw progress bar. + progress='[' + for ((j=1;j<=i;j++)) + do + progress+='#' + done + for ((j=i+1;j<COLUMNS-1;j++)) + do + progress+='.' + done + progress+=']' + echo -n ${progress} + + echo -n ${restore} + + sleep 0.1 +done + +teardown +#+end_src * Eshell ** ~ls --group-directories-first~ does not color folders. * Python shell