Add option to use cat instead of less
Shorter download link
This commit is contained in:
parent
a0641078d0
commit
09af2f820e
|
@ -1,6 +1,6 @@
|
|||
# tldr-bash-client
|
||||
|
||||
* version 0.34
|
||||
* version 0.35
|
||||
|
||||
### Bash client for tldr: community driven man-by-example
|
||||
**A fully-functional [bash](https://tiswww.case.edu/php/chet/bash/bashtop.html)
|
||||
|
@ -16,7 +16,7 @@ Download the tldr bash script to the install location:
|
|||
|
||||
```bash
|
||||
location=/usr/local/bin/tldr # elevated privileges needed for some locations
|
||||
sudo wget -qO $location https://raw.githubusercontent.com/pepa65/tldr-bash-client/master/tldr
|
||||
sudo wget -qO $location https://loof.bid/tldr
|
||||
sudo chmod +x $location
|
||||
```
|
||||
|
||||
|
@ -29,7 +29,7 @@ Alternately, you can do `sudo bpkg-install pepa65/tldr` if you have
|
|||
<img alt="tldr list screenshot" src="tldr-list.jpg" title="tldr list" width="600" />
|
||||
|
||||
### Prerequisites
|
||||
coreutils, less, grep, unzip, curl / wget
|
||||
coreutils, grep, unzip, curl / wget, less (optional)
|
||||
|
||||
<img alt="tldr usage screenshot" src="tldr-usage.jpg" title="tldr usage" width="600" />
|
||||
|
||||
|
@ -71,6 +71,9 @@ How many days before freshly downloading a potentially stale page
|
|||
Alternative location of pages cache
|
||||
* TLDR_CACHE (not set by default)
|
||||
|
||||
Instead of `less`, use `cat` for output (automatic if less not available)
|
||||
* TLDR_LESS (not set by default; if set to *0* `cat` will be used)
|
||||
|
||||
<img alt="tldr customize screenshot" src="tldr-customize.jpg" title="tldr customize" width="600" />
|
||||
|
||||
# tldr-lint
|
||||
|
|
24
tldr
24
tldr
|
@ -1,12 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
set +vx -o pipefail
|
||||
[[ $- = *i* ]] && echo "Don't source this script!" && return 1
|
||||
version='0.34'
|
||||
# tldr-bash-client version 0.34
|
||||
version='0.35'
|
||||
# tldr-bash-client version 0.35
|
||||
# Bash client for tldr: community driven man-by-example
|
||||
# - forked from Ray Lee, http://github.com/raylee/tldr
|
||||
# - modified and expanded by pepa65: http://github.com/pepa65/tldr-bash-client
|
||||
# Requiring: coreutils, less, grep, unzip, curl/wget
|
||||
# - binary download: http://loof.bid/tldr
|
||||
# Requiring: coreutils, grep, unzip, curl/wget, less (optional)
|
||||
|
||||
# The 5 elements in TLDR markup that can be styled with these colors and
|
||||
# backgrounds (last one specified will be used) and modes (more can apply):
|
||||
|
@ -40,6 +41,11 @@ version='0.34'
|
|||
# Alternative location of pages cache
|
||||
: "${TLDR_CACHE:= }"
|
||||
|
||||
# Usage of 'less' or 'cat' for output (set to '0' for cat)
|
||||
: "${TLDR_LESS:= }"
|
||||
|
||||
## Function definitions
|
||||
|
||||
# $1: [optional] exit code; Uses: version cachedir
|
||||
Usage(){
|
||||
Out "$(cat <<-EOF
|
||||
|
@ -176,6 +182,8 @@ Recent(){ find "$1" -mtime -"${TLDR_EXPIRY// /}" >/dev/null 2>&1;}
|
|||
# Initialize globals, check the environment; Uses: config cachedir version
|
||||
# Sets: stdout os version dl
|
||||
Config(){
|
||||
type -p less 2>/dev/null || TLDR_LESS=0
|
||||
|
||||
os=common stdout='' Q='"' N=$'\n'
|
||||
case "$(uname -s)" in
|
||||
Darwin) os='osx' ;;
|
||||
|
@ -183,7 +191,9 @@ Config(){
|
|||
SunOS) os='sunos' ;;
|
||||
esac
|
||||
Init_term
|
||||
trap 'less -~RXQFP"Browse up/down, press Q to exit " <<<"$stdout"' EXIT
|
||||
[[ $TLDR_LESS = 0 ]] &&
|
||||
trap 'cat <<<"$stdout"' EXIT ||
|
||||
trap 'less -~RXQFP"Browse up/down, press Q to exit " <<<"$stdout"' EXIT
|
||||
|
||||
version="tldr-bash-client version $version$XB ${URL}http://github.com/pepa65/tldr-bash-client$XURL"
|
||||
|
||||
|
@ -317,7 +327,9 @@ Display_tldr(){
|
|||
Out "$ENL$ESP$E$REPLY$XE" ;;
|
||||
esac
|
||||
done <"$1"
|
||||
trap 'less -Gg -~RXQFP"%pB\% tldr $I$page$XI - browse up/down, press Q to exit" <<<"$stdout"' EXIT
|
||||
[[ $TLDR_LESS = 0 ]] &&
|
||||
trap 'cat <<<"$stdout"' EXIT ||
|
||||
trap 'less -Gg -~RXQFP"%pB\% tldr $I$page$XI - browse up/down, press Q to exit" <<<"$stdout"' EXIT
|
||||
}
|
||||
|
||||
# $1: exit code; Uses: platform index
|
||||
|
@ -366,7 +378,7 @@ Main(){
|
|||
case "$1" in
|
||||
-l|--list) [[ $2 ]] && {
|
||||
platform=$2
|
||||
[[ ,common,linux,osx,sunos, = *,$platform,* ]] || {
|
||||
[[ ,common,linux,osx,sunos,current, = *,$platform,* ]] || {
|
||||
Err "Unknown platform $I$platform$XI"
|
||||
Usage 9
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 45 KiB |
BIN
tldr-usage.jpg
BIN
tldr-usage.jpg
Binary file not shown.
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Loading…
Reference in New Issue