mirror of
https://github.com/endeavouros-team/eos-bash-shared.git
synced 2026-06-13 01:34:36 +00:00
[eos-bash-shared] little fix in nano-pager
This commit is contained in:
+12
-4
@@ -1,19 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
NanoPager() { # a pager based on 'nano' editor
|
||||
# A pager based on 'nano' editor.
|
||||
# nano-pager can be used in two simple ways:
|
||||
#
|
||||
# 1. via a pipe: ls -la | nano-pager
|
||||
# or
|
||||
# 2. like a standard command: nano-pager readme.txt
|
||||
#
|
||||
|
||||
NanoPager() {
|
||||
local file="$1"
|
||||
local progname=${0##*/}
|
||||
local -r nano=/bin/nano
|
||||
if [ -x $nano ] ; then
|
||||
local cmd="$nano +1 --view -"
|
||||
local cmd="$nano +1 --modernbindings --view"
|
||||
if [ "$file" ] ; then
|
||||
if [ -e "$file" ] ; then
|
||||
cat "$file" | $cmd # e.g. NanoViewer readme.txt
|
||||
$cmd "$file"
|
||||
else
|
||||
echo "==> $progname: file $file not found" >&2
|
||||
fi
|
||||
else
|
||||
$cmd # e.g. ls -la | NanoViewer
|
||||
$cmd -
|
||||
fi
|
||||
else
|
||||
echo "==> $progname: 'nano' is not installed" >&2
|
||||
|
||||
Reference in New Issue
Block a user