mirror of
https://github.com/pepa65/tldr-bash-client.git
synced 2024-11-01 09:01:01 +01:00
Compare commits
No commits in common. "master" and "v0.6.1" have entirely different histories.
@ -1,6 +1,6 @@
|
|||||||
# tldr-bash-client
|
# tldr-bash-client
|
||||||
|
|
||||||
* version 0.6.2
|
* version 0.6.1
|
||||||
|
|
||||||
### Bash client for tldr: community driven man-by-example
|
### Bash client for tldr: community driven man-by-example
|
||||||
**A fully-functional [bash](https://tiswww.case.edu/php/chet/bash/bashtop.html)
|
**A fully-functional [bash](https://tiswww.case.edu/php/chet/bash/bashtop.html)
|
||||||
|
28
tldr
28
tldr
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set +vx -o pipefail
|
set +vx -o pipefail
|
||||||
[[ $- = *i* ]] && echo "Don't source this script!" && return 1
|
[[ $- = *i* ]] && echo "Don't source this script!" && return 1
|
||||||
version=0.6.2
|
version='0.6.1'
|
||||||
# tldr-bash-client v0.6.2
|
# tldr-bash-client v0.6.1
|
||||||
# Bash client for tldr: community driven man-by-example
|
# Bash client for tldr: community driven man-by-example
|
||||||
# - forked from Ray Lee, https://github.com/raylee/tldr
|
# - forked from Ray Lee, https://github.com/raylee/tldr
|
||||||
# - modified and expanded by pepa65: https://gitlab.com/pepa65/tldr-bash-client
|
# - modified and expanded by pepa65: https://gitlab.com/pepa65/tldr-bash-client
|
||||||
@ -182,7 +182,7 @@ Init_term(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
# $1: page
|
# $1: page
|
||||||
Recent(){ [[ $(find "$1" -mtime -"$TLDR_EXPIRY" 2>/dev/null) ]];}
|
Recent(){ [[ $(find "$1" -mtime -"$TLDR_EXPIRY") ]];}
|
||||||
|
|
||||||
# Initialize globals, check the environment; Uses: config cachedir version
|
# Initialize globals, check the environment; Uses: config cachedir version
|
||||||
# Sets: stdout os version dl pages
|
# Sets: stdout os version dl pages
|
||||||
@ -210,8 +210,8 @@ Config(){
|
|||||||
ver="tldr-bash-client version $version$XB ${URL}https://gitlab.com/pepa65/tldr-bash-client$XURL"
|
ver="tldr-bash-client version $version$XB ${URL}https://gitlab.com/pepa65/tldr-bash-client$XURL"
|
||||||
|
|
||||||
# Select download method
|
# Select download method
|
||||||
! dl="$(type -P curl) --connect-timeout 10 -sLfo" &&
|
! dl="$(type -P curl) -sLfo" &&
|
||||||
! dl="$(type -P wget) --timeout=10 --max-redirect=20 -qNO" &&
|
! dl="$(type -P wget) --max-redirect=20 -qNO" &&
|
||||||
Err "tldr requires ${I}curl$XI or ${I}wget$XI installed in your path" &&
|
Err "tldr requires ${I}curl$XI or ${I}wget$XI installed in your path" &&
|
||||||
exit 3
|
exit 3
|
||||||
|
|
||||||
@ -492,21 +492,9 @@ Main(){
|
|||||||
Usage 27
|
Usage 27
|
||||||
[[ $platform = all ]] && platform=
|
[[ $platform = all ]] && platform=
|
||||||
Get_tldr "${page// /-}"
|
Get_tldr "${page// /-}"
|
||||||
if [[ -s $cached ]]
|
[[ ! -s $cached ]] && Err "tldr page for command $I$page$XI not found" \
|
||||||
then # File present
|
&& Inf "Contribute new pages at:$XB ${URL}https://github.com/tldr-pages/tldr$XURL" && exit 28
|
||||||
((markdown)) && Out "$(cat "$cached")" || Display_tldr "$cached"
|
((markdown)) && Out "$(cat "$cached")" || Display_tldr "$cached"
|
||||||
elif [[ ! $lang = en ]]
|
|
||||||
then # Not English and no file
|
|
||||||
pages=pages
|
|
||||||
Get_tldr "${page// /-}"
|
|
||||||
[[ -s $cached ]] &&
|
|
||||||
Err "tldr page for command $I$page$XI not found in '$lang' but found in English" &&
|
|
||||||
((markdown)) && Out "$(cat "$cached")" ||
|
|
||||||
Display_tldr "$cached"
|
|
||||||
else # Just not found
|
|
||||||
Err "tldr page for command $I$page$XI not found" &&
|
|
||||||
Inf "Contribute new pages at:$XB ${URL}https://github.com/tldr-pages/tldr$XURL" && exit 28
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
|
Loading…
Reference in New Issue
Block a user