

Better HN search with bash - ekns

The interface for Algolia search is horrible for picking date ranges so I made this little bash function to fix it (noting that &quot;open&quot; is an alias to &quot;xdg-open&quot; for me on Linux).<p>Might work in other shells too.<p><pre><code>  function hn() {
      if test $# -lt 1 || test $# -gt 3; then
          echo &quot;Usage: $0 &lt;query&gt; [start=1970] [end=now]&quot;
          echo &quot;start and end are ISO dates like 2014-03-23.&quot;
          return 1
      fi
      query=$1
      start=$(test $# -gt 1 &amp;&amp; date --date &quot;$2&quot; +%s || date --date @0 +%s)
      end=$(test $# -gt 2 &amp;&amp; date --date &quot;$3&quot; +%s || date +%s)
      url=&quot;https:&#x2F;&#x2F;hn.algolia.com&#x2F;?sort=byPopularity&amp;prefix=false&amp;page=0&amp;type=story&amp;query=${query}&amp;dateRange=custom&amp;dateStart=${start}&amp;dateEnd=${end}&quot;
      echo $url
      open &quot;$url&quot;
  }</code></pre>
======
redox_
Indeed, we never took the time to plug a date parser. Any chance you've time
for a pull-request? [https://github.com/algolia/hn-
search/blob/master/app/assets/...](https://github.com/algolia/hn-
search/blob/master/app/assets/javascripts/controllers.js#L26) and
[https://github.com/algolia/hn-
search/blob/master/app/control...](https://github.com/algolia/hn-
search/blob/master/app/controllers/api/v1/base_controller.rb#L7) :)

That would be cool!

