better deleting

This commit is contained in:
Emma Tebibyte 2023-07-13 15:35:38 -06:00
parent 9242bbfa6c
commit de2bce40ee

14
en
View File

@ -12,13 +12,13 @@ exec >&2 </dev/tty
if test -z "$1"; then
printf "Usage: %s file...\n" "$argv0" 1>&2
exit 1
exit 64 # sysexits.h(3) EX_USAGE
fi
if ! command -v mktemp >/dev/null 2>&1
then
printf "%s: mktemp(1): Missing dependency." "$argv0"
exit 1
exit 69 # sysexits.h(3) EX_UNAVAILABLE
fi
help="$(printf "Commands:\n\
@ -39,13 +39,13 @@ en(1) Copyright (c) 2023 Emma Tebibyte\n")"
while test -n "$1"; do
content="$(cat "$1")"
file="$(printf "%s\n" "$1" | tr -d '/')"
temp_highlight="$(mktemp -t "XXXXX$file")"
# use bat for syntax highlighting if its available, but remove the frills
if command -v bat >/dev/null
then
# there has to be a temp file for writing the highlighted text to
syntax_h() {
temp_highlight="$(mktemp -t "XXXXX$file")"
printf "%s\n" "$1" >"$temp_highlight"
bat -pp --color always "$temp_highlight"
}
@ -66,7 +66,7 @@ while test -n "$1"; do
;;
"a")
read -r append
content="$(printf "%s\n%s" "$content" "$append")"
content="$content$append"
;;
"c")
clear
@ -77,8 +77,10 @@ while test -n "$1"; do
else
for line in $(printf "%s\n" "$args" | sed 's/,/\n/g')
do
del="$(printf "%s\n" "$content" | head -n "$line" | tail -n 1)"
content="$(printf "%s\n" "$content" | sed -n "/$del/!p")"
content="$(printf "%s\n" "$content" |\
awk -v l="$line" 'NR == l {next} {print}')"
#del="$(printf "%s\n" "$content" | head -n "$line" | tail -n 1)"
#content="$(printf "%s\n" "$content" | sed -n "/$del/!p")"
done
fi
;;