commit eb1b9564ae574b9655e5547f316b8f8e9d02d855
parent 951a4b5e3533f21475b7655f6ac4193e13353c09
Author: William Casarin <jb55@jb55.com>
Date: Wed, 28 Oct 2020 15:09:06 -0700
lessr: readonly dir fallback
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 8 insertions(+), 0 deletions(-)
diff --git a/bin/lessr b/bin/lessr
@@ -5,5 +5,13 @@ base=$(basename "$1")
export LESSHISTFILE="$dir/.$base.hst"
+# use a fallback dir if it's not writable
+if [[ ! -w "$LESSHISTFILE" ]]
+then
+ dir="$HOME/var/marks"
+ mkdir -p "$dir"
+ export LESSHISTFILE="$dir/.$base.hst"
+fi
+
# export LESS="-cix8JRM --save-marks"
exec less -J --save-marks "$@"