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