-
Notifications
You must be signed in to change notification settings - Fork 6
Description
By default, when less exits, the text it was displaying is cleared and the user's terminal window is returned to the state it was in prior to less being invoked.
I think this is a vital feature of less, and of short-lived interactive CLI utilities in general (programs like fzf, bat, etc. also implement this feature).
Peep's selling point seems to be its focus on not displacing the surrounding terminal context; I think that the functionality I just described would be very complementary to this focus.
As a workaround, I wrote a little wrapper script which basically accomplishes this (requires ncurses):
#!/bin/bash
set -euo pipefail
function isset_help() {
local opt
for opt in "$@"; do
case "$opt" in
--)
echo 0
return 0
;;
--help)
echo 1
return 0
;;
esac
done
while getopts ':h' opt "$@"; do
case "$opt" in
h)
echo 1
return 0
;;
*)
continue
;;
esac
done
echo 0
return 0
}
function main() {
local -i h
h=$(isset_help "$@")
[[ $h -eq 0 ]] && tput sc
peep "$@"
local -i c=$?
[[ $c -eq 0 && $h -eq 0 ]] && tput rc
return $c
}
main "$@"
Before:
2021-01-12_23-43-44_Alacritty.mp4
After:
2021-01-12_23-47-02_Alacritty.mp4
It's far from ideal and doesn't work when the cursor line is at or within --lines
of the bottom of the terminal window, but it should give you an idea of what I am proposing.
Thanks for creating this project, I really love using it!