Adds pager option and uses $PAGER environment variable
Due to bat also reading the $PAGER environment variable, I first look to see if bat is available. If it is, I use that. If it isn't, I use the $PAGER environment variable. If that's not available, I use cat. I also added the --editor flag to the help output which had clearly been missed Close #12
This commit is contained in:
parent
90cef0d7c0
commit
0ac730ca3c
2 changed files with 9 additions and 1 deletions
8
kb
8
kb
|
@ -89,6 +89,11 @@ args=()
|
|||
dataDir="${XDG_DATA_HOME:=$HOME/.local/share}/kb/"
|
||||
sqliteFile=""
|
||||
editor="${EDITOR:=vim}"
|
||||
if type -p bat > /dev/null 2>&1; then
|
||||
pager="bat"
|
||||
else
|
||||
pager="${PAGER:=cat}"
|
||||
fi
|
||||
|
||||
# Check for Dependencies
|
||||
# -----------------------------------
|
||||
|
@ -373,6 +378,8 @@ usage() {
|
|||
-h, --help Display this help and exit
|
||||
--data <directory> The knowledgebase data dir
|
||||
--sqlite <file> The sqlite file (default to <data>/knowledgebase.sqlite3
|
||||
--editor <editor> The editor to use (default $EDITOR or vim)
|
||||
--pager <editor> The pager to use (default bat or $PAGER or cat)
|
||||
--nogit Don't run git commands
|
||||
--version Output version information and exit
|
||||
|
||||
|
@ -446,6 +453,7 @@ while [[ $1 = -?* ]]; do
|
|||
--data) dataDir="$2"; shift ;;
|
||||
--sqlite) sqliteFile="$2"; shift ;;
|
||||
--editor) editor="$2"; shift ;;
|
||||
--pager) pager="$2"; shift ;;
|
||||
--nogit) dogit=0 ;;
|
||||
--) shift; break ;;
|
||||
*) die "invalid option: '$1'." ;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue