mirror of
https://github.com/endeavouros-team/eos-bash-shared.git
synced 2026-06-13 01:34:36 +00:00
33 lines
731 B
Bash
Executable File
33 lines
731 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# 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 --modernbindings --view"
|
|
if [ "$file" ] ; then
|
|
if [ -e "$file" ] ; then
|
|
$cmd "$file"
|
|
else
|
|
echo "==> $progname: file $file not found" >&2
|
|
fi
|
|
else
|
|
$cmd -
|
|
fi
|
|
else
|
|
echo "==> $progname: 'nano' is not installed" >&2
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
NanoPager "$@"
|