about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xmless11
1 files changed, 10 insertions, 1 deletions
diff --git a/mless b/mless
index b859a15..08ce513 100755
--- a/mless
+++ b/mless
@@ -22,7 +22,16 @@ if [ "$1" = --filter ]; then
 	fi
 
 	mseq -C "$2"
-	mscan .-2:.+3 2>/dev/null | colorscan
+
+	total=$(mscan -n -- -1)
+	case $2 in
+		1)              mscan .-0:.+5 ;;
+		2)              mscan .-1:.+4 ;;
+		$((total - 2))) mscan .-3:.+2 ;;
+		$((total - 1))) mscan .-4:.+1 ;;
+		$total)         mscan .-5:.+0 ;;
+		*)              mscan .-2:.+3 ;;
+	esac 2>/dev/null | colorscan
 	echo
 
 	if ! [ -f "$(mseq -r "$2")" ]; then