-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheat
executable file
·29 lines (26 loc) · 850 Bytes
/
cheat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
## Author: rwxrob
## difference between $* and $@? Both hold list of all arguments passed to
## script. However the values are not the same if surrounded by double quotes:
## - $@ expanded as "$1" "$2" "$3" ... "$n"
## - $* expanded as "$1y$2y$3y...$n", where y is the value of IFS variable i.e.
## "$*" is one long string and $IFS act as an separator or token delimiters.
# IFS=+
# echo $*
# echo "$*"
# echo
# echo $@
# echo "$@"
# exit
## Alternatives: `tldr` and `howdoi`
[[ "$1" == -h || "$1" == --help || "$1" == :help ]] && curl -sS https://cht.sh/:help | bat && exit
[ "$1" == :list ] && curl -sS https://cht.sh/:list | bat && exit
[ "$1" == :intro ] && curl -sS https://cht.sh/:intro | bat && exit
cheat() {
language="$1"
if [ $# -ge 1 ]; then
shift
fi
IFS=+; curl -sS https://cht.sh/$language/"$*"
}
cheat "$@"