commit dcd9753519c69b18e764d8df5b88d3e1ca869e14 parent 548acb4010b87a3287ef15055ec5dc3c67619ed9 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Fri, 4 Jan 2019 08:32:22 +0100 Split shdl into separate script with torsocks Diffstat:
M | links/.commands.sh | | | 1 | - |
M | links/bin/shdl | | | 14 | +++++++++++++- |
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/links/.commands.sh b/links/.commands.sh @@ -166,7 +166,6 @@ news() { ## web services -shdl() { curl -O $(curl -s http://sci-hub.tw/"$@" | grep location.href | grep -o http.*pdf) ;} alias youtube-dl='youtube-dl --format mp4' weather() { curl "wttr.in/?m"; } define() { curl --silent dict://dict.org/d:"$1"; } diff --git a/links/bin/shdl b/links/bin/shdl @@ -1,8 +1,20 @@ #!/usr/bin/env bash set -e +read -p "use torsocks? [Y/n] " -n 1 -r +echo +if [[ $REPLY =~ ^[Nn]$ ]]; then + prefix="" +else + prefix="torsocks" +fi + shdl() { - curl -O $(curl -s http://sci-hub.tw/"$@" | grep location.href | grep -o http.*pdf) + url=$($prefix curl -s http://sci-hub.tw/"$@" | \ + grep location.href | \ + grep -o \/\/.*pdf | sed 's/^/http:/') + echo $url + $prefix curl -O "$url" } shdl "$@"