mirror of
https://github.com/chubin/cheat.sh
synced 2024-11-14 15:07:09 +00:00
new config option: CHTSH_CURL_OPTIONS (fixes #80)
This commit is contained in:
parent
8d12aabe56
commit
8e89907c28
2 changed files with 26 additions and 17 deletions
|
@ -305,6 +305,7 @@ QUERY_OPTIONS="style=native"
|
|||
Other cht.sh configuration parameters:
|
||||
|
||||
```
|
||||
CHTSH_CURL_OPTIONS="-A curl" # curl options used for cht.sh queries
|
||||
CHTSH_URL=https://cht.sh # URL of the cheat.sh server
|
||||
```
|
||||
|
||||
|
|
|
@ -39,22 +39,6 @@ if echo $KSH_VERSION | grep -q ' 93' && ! local foo 2>/dev/null; then
|
|||
alias local=typeset
|
||||
fi
|
||||
|
||||
# any better test not involving either OS matching or actual query?
|
||||
if [ `uname -s` = OpenBSD ] && [ -x /usr/bin/ftp ]; then
|
||||
curl() {
|
||||
local opt args="-o -"
|
||||
while getopts "b:s" opt; do
|
||||
case $opt in
|
||||
b) args="$args -c $OPTARG";;
|
||||
s) args="$args -M -V";;
|
||||
*) echo "internal error: unsupported cURL option '$opt'" >&2; exit 1;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
/usr/bin/ftp $args "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
get_query_options()
|
||||
{
|
||||
local query="$*"
|
||||
|
@ -144,6 +128,31 @@ fi
|
|||
|
||||
[ -z "$CHTSH_URL" ] && CHTSH_URL=https://cht.sh
|
||||
|
||||
# any better test not involving either OS matching or actual query?
|
||||
if [ `uname -s` = OpenBSD ] && [ -x /usr/bin/ftp ]; then
|
||||
curl() {
|
||||
local opt args="-o -"
|
||||
while getopts "b:s" opt; do
|
||||
case $opt in
|
||||
b) args="$args -c $OPTARG";;
|
||||
s) args="$args -M -V";;
|
||||
*) echo "internal error: unsupported cURL option '$opt'" >&2; exit 1;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
/usr/bin/ftp $args "$@"
|
||||
}
|
||||
else
|
||||
command -v curl >/dev/null || { echo 'DEPENDENCY: install "curl" to use cht.sh' >&2; exit 1; }
|
||||
_CURL=$(command -v curl)
|
||||
if [ x"$CHTSH_CURL_OPTIONS" != x ]; then
|
||||
curl() {
|
||||
$_CURL ${CHTSH_CURL_OPTIONS} "$@"
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$1" = --read ]; then
|
||||
read -r a || a=exit
|
||||
printf "%s\n" "$a"
|
||||
|
@ -200,7 +209,6 @@ if [ "$is_macos" != yes ]; then
|
|||
command -v xsel >/dev/null || echo 'DEPENDENCY: please install "xsel" for "copy"' >&2
|
||||
fi
|
||||
command -v rlwrap >/dev/null || { echo 'DEPENDENCY: install "rlwrap" to use cht.sh in the shell mode' >&2; exit 1; }
|
||||
command -v curl >/dev/null || { echo 'DEPENDENCY: install "curl" to use cht.sh' >&2; exit 1; }
|
||||
|
||||
mkdir -p "$HOME/.cht.sh/"
|
||||
lines=$(tput lines)
|
||||
|
|
Loading…
Reference in a new issue