Browse Hacker News like a haxor: A Hacker News command line interface (CLI).

Overview

Imgur

Build Status

PyPI version PyPI License

haxor-news

Coworker who sees me looking at something in a browser: "Glad you're not busy; I need you to do this, this, this..."

Coworker who sees me staring intently at a command prompt: Backs away, slowly...

-Source

Check out the haxor-news discussion in this Hacker News post.

haxor-news brings Hacker News to the terminal, allowing you to view/filter the following without leaving your command line:

  • Posts
  • Post Comments
  • Post Linked Web Content
  • Monthly Hiring and Freelancers Posts
  • User Info
  • Onions

haxor-news helps you filter the large number of comments that popular posts generate.

  • Want to expand only previously unseen comments?
    • -cu/--comments_unseen
  • How about recent comments posted in the past 60 minutes?
    • -cr/--comments_recent
  • Filter comments matching a regex query?
    • -cq/--comments_query [query]

Imgur

Job hunting or just curious what's out there? Filter the monthly who's hiring and freelancers post:

remote_web_jobs.txt">
$ hn hiring "(?i)(Node|JavaScript).*(remote)" > remote_web_jobs.txt

Combine haxor-news with pipes, redirects, and other command line utilities. Output to pagers, write to files, automate with cron, etc.

haxor-news comes with a handy optional auto-completer with interactive help:

Imgur

Index

General

Features

Installation and Tests

Misc

Syntax

Usage:

$ hn  [params] [options]

Auto-Completer and Interactive Help

Optionally, you can enable fish-style completions and an auto-completion menu with interactive help:

$ haxor-news

If available, the auto-completer also automatically displays comments through a pager.

Within the auto-completer, the same syntax applies:

haxor> hn  [params] [options]

Imgur

Imgur

Customizable Highlighting

You can control the ansi colors used for highlighting by updating your ~/.haxornewsconfig file.

Color options include:

'black', 'red', 'green', 'yellow',
'blue', 'magenta', 'cyan', 'white'

For no color, set the value(s) to None.

Imgur

Commands

Imgur

View Posts

View the Top, Best, Show, Ask, Jobs, New, and Onion posts.

Usage:

$ hn [command] [limit]  # post limit default: 10

Examples:

$ hn top
$ hn show 20

Imgur

View a Post's Linked Web Content

After viewing a list of posts, you can view a post's linked web content by referencing the post #.

The HTML contents of the post's link are formatted for easy-viewing within your terminal. If available, the formatted output is sent to a pager.

See the View in a Browser section to view the contents in a browser instead.

Usage:

$ hn view [#]

Example:

$ hn view 1
$ hn view 8

Imgur

View and Filter a Post's Comments

View All Comments

After viewing a list of posts, you can view a post's comments by referencing the post #.

Examples:

$ hn view 8 -c
$ hn view 8 --comments > comments.txt

Paged Comments

If running with the auto-completer, comments are automatically paginated. To get the same pagination without the auto-completer, append | less -r:

$ hn view 8 -c | less -r

Imgur

Filter on Unseen Comments

Filter comments to expand only those you have not yet seen. Unseen comments are denoted with a [!] and are fully expanded.

Seen comments will be truncated with [...] and will be shown to help provide context to unseen comments.

Examples:

$ hn view 8 -cu
$ hn view 8 --comments_unseen | less -r

Imgur

Filter on Recent Comments

Filter comments to expand only those posted within the past 60 minutes.

Older comments will be truncated with [...] and will be shown to help provide context to recent comments.

Examples:

$ hn view 8 -cr | less -r
$ hn view 8 --comments_recent

Imgur

Filter with Regex

Filter comments based on a given regular expression query.

Examples:

programmer.txt">
$ hn view 2 -cq "(?i)programmer" | less -r
$ hn view 2 --comments_regex_query "(?i)programmer" > programmer.txt

Case insensitive regex: (?i)

Imgur

Hide Non-Matching Comments

When filtering comments for unseen, recent, or with regex, non-matching comments are collapsed to provide context. To instead hide non-matching comments, pass the -ch\--comments_hide flag. Hidden comments will be displayed as ..

Example:

$ hn view 8 -cu -ch | less -r

Imgur

Filter the Monthly Hiring Post

Hacker News hosts a monthly hiring post where employers post the latest job openings.

Usage:

$ hn hiring [regex filter]

Examples:

remote_jobs.txt">
$ hn hiring ""
$ hn hiring "(?i)JavaScript|Node"
$ hn hiring "(?i)(Node|JavaScript).*(remote)" > remote_jobs.txt

Case insensitive regex: (?i)

Imgur

To search a different monthly hiring post other than the latest, use the hiring post id.

Usage:

$ hn hiring [regex filter] [post id]

Filter the Freelancers Post

Hacker News hosts a monthly freelancers post where employers and freelancers post availabilities.

Usage:

$ hn freelance [regex filter]

Examples:

remote_jobs.txt">
$ hn freelance ""
$ hn freelance "(?i)JavaScript|Node"
$ hn freelance "(?i)(Node|JavaScript).*(remote)" > remote_jobs.txt

Case insensitive regex: (?i)

Imgur

To search a different monthly hiring post other than the latest, use the hiring post id.

Usage:

$ hn freelance [regex filter] [post id]

Combine With Pipes and Redirects

Output to pagers, write to files, automate with cron, etc.

Examples:

remote_jobs.txt">
$ hn view 1 -c | less
$ hn freelance "(?i)(Node|JavaScript).*(remote)" > remote_jobs.txt

Imgur

View User Info

Usage:

$ hn user [user id]

Imgur

View Onions

Usage:

$ hn onion [limit]  # post limit default: all

Imgur

View in a Browser

View the linked web content or comments in your default browser instead of your terminal.

Usage:

$ hn  [params] [options] -b
$ hn  [params] [options] --browser

Windows Support

haxor-news has been tested on Windows 10.

Pager Support

Pager support on Windows is more limited as discussed in the following ticket. Users can direct output to a pager with the | more command:

$ hn view 1 -c | more

Config File

On Windows, the .haxornewsconfig file can be found in %userprofile%. For example:

C:\Users\dmartin\.haxornewsconfig

cmder and conemu

Although you can use the standard Windows command prompt, you'll probably have a better experience with either cmder or conemu.

Installation

Pip Installation

PyPI version PyPI

haxor-news is hosted on PyPI. The following command will install haxor-news:

$ pip install haxor-news

You can also install the latest haxor-news from GitHub source which can contain changes not yet pushed to PyPI:

$ pip install git+https://github.com/donnemartin/haxor-news.git

If you are not installing in a virtualenv, run with sudo:

$ sudo pip install haxor-news

Once installed, run the optional haxor-news auto-completer with interactive help:

$ haxor-news

Run commands:

$ hn  [params] [options]

Virtual Environment Installation

It is recommended that you install Python packages in a virtualenv to avoid potential issues with dependencies or permissions.

To view haxor-news virtualenv installation instructions, click here.

Mac OS X 10.11 El Capitan Users

There is a known issue with Apple and its included python package dependencies (more info at https://github.com/pypa/pip/issues/3165). We are investigating ways to fix this issue but in the meantime, to install haxor-news, you can run:

$ sudo pip install haxor-news --upgrade --ignore-installed six

Supported Python Versions

  • Python 2.6
  • Python 2.7
  • Python 3.3
  • Python 3.4
  • Python 3.5
  • Python 3.6
  • Python 3.7

Supported Platforms

  • Mac OS X
    • Tested on OS X 10.10
  • Linux, Unix
    • Tested on Ubuntu 14.04 LTS
  • Windows
    • Tested on Windows 10

Developer Installation

If you're interested in contributing to haxor-news, run the following commands:

$ git clone https://github.com/donnemartin/haxor-news.git
$ pip install -e .
$ pip install -r requirements-dev.txt
$ haxor-news
$ hn  [params] [options]

Continuous Integration

Build Status

Continuous integration details are available on Travis CI.

Unit Tests and Code Coverage

Run unit tests in your active Python environment:

$ python tests/run_tests.py

Run unit tests with tox on multiple Python environments:

$ tox

Documentation

Source code documentation will soon be available on Readthedocs.org. Check out the source docstrings.

Run the following to build the docs:

$ scripts/update_docs.sh

Contributing

Contributions are welcome!

Review the Contributing Guidelines for details on how to:

  • Submit issues
  • Submit pull requests

Credits

Contact Info

Feel free to contact me to discuss any issues, questions, or comments.

My contact info can be found on my GitHub page.

License

I am providing code and resources in this repository to you under an open source license. Because this is my personal repository, the license you receive to my code and resources is from me and not my employer (Facebook).

License

Copyright 2015 Donne Martin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • Error

    Error "wrong color format 'reverse'"

    Installed haxor-news today on Arch. I get this error

    8:36:35 [email protected] ~ haxor-news
    Traceback (most recent call last):
      File "/usr/bin/haxor-news", line 11, in <module>
        load_entry_point('haxor-news==0.4.1', 'console_scripts', 'haxor-news')()
      File "/usr/lib/python3.6/site-packages/haxor_news/main.py", line 25, in cli
        haxor = Haxor()
      File "/usr/lib/python3.6/site-packages/haxor_news/haxor.py", line 110, in __init__
        self._create_cli()
      File "/usr/lib/python3.6/site-packages/haxor_news/haxor.py", line 153, in _create_cli
        style_factory = StyleFactory(self.theme)
      File "/usr/lib/python3.6/site-packages/haxor_news/style.py", line 31, in __init__
        self.style = self.style_factory(name)
      File "/usr/lib/python3.6/site-packages/haxor_news/style.py", line 49, in style_factory
        class CliStyle(Style):
      File "/usr/lib/python3.6/site-packages/pygments/style.py", line 101, in __new__
        ndef[0] = colorformat(styledef)
      File "/usr/lib/python3.6/site-packages/pygments/style.py", line 58, in colorformat
        assert False, "wrong color format %r" % text
    AssertionError: wrong color format 'reverse'
    
    bug 
    opened by AntouanK 8
  • Error 'failed to create process' when user profile folder contains a blank space

    Error 'failed to create process' when user profile folder contains a blank space

    I think that this is more an observation than an issue as such.

    I installed haxor-news, on a Windows 10 machine, and the installation process was seamless, but when I tried to launch it, it constantly keeps telling me that it "failed to create process".

    After a while, and reading a couple of blogs, and stackoverflow articles, I came to the realization/discovery that the root of my problem was that my username contains an empty space (that is "Antonio Gil") and for some reason, that I don't fully understand, that little details was causing the issue.

    The fix? I just changed the first line of both scipts (haxor-news-script.py and hn-script.py) from:

    #!c:\users\antonio gil\appdata\local\programs\python\python35\python.exe
    

    to

    #!"c:\users\antonio gil\appdata\local\programs\python\python35\python.exe"
    

    And that was all to get haxor-news work as expected.

    Probably it was just a "newbie error" (never use python, or pip before), but I guess that it should be great to consider that detail.

    Best regards!

    bug 
    opened by antonio-gil 8
  • Test failures on NixOS

    Test failures on NixOS

    When I run the tests on NixOS, I get the following output:

    test_cli (unittest.loader.ModuleImportFailure) ... ERROR
    test_F10 (test_keys.KeysTest) ... ERROR
    test_F2 (test_keys.KeysTest) ... ERROR
    test_toolbar_off (test_toolbar.ToolbarTest) ... ERROR
    test_toolbar_on (test_toolbar.ToolbarTest) ... ERROR
    test_clear_item_cache (test_config.ConfigTest) ... ok
    test_config (test_config.ConfigTest) ... ok
    test_load_hiring_and_freelance_ids (test_config.ConfigTest) ... FAIL
    test_load_hiring_and_freelance_ids_from_cache_or_defaults (test_config.ConfigTest) ... ok
    test_load_hiring_and_freelance_ids_invalid_url (test_config.ConfigTest) ... ERROR
    test_save_and_load_item_ids (test_config.ConfigTest) ... ERROR
    test_view_comment_clear_cache (test_config.ConfigTest) ... ok
    test_add_comment_pagination (test_haxor.HaxorTest) ... ERROR
    test_exit_command (test_haxor.HaxorTest) ... ERROR
    test_run_command (test_haxor.HaxorTest) ... ERROR
    test_arg_freelance (test_completer.CompleterTest) ... ok
    test_arg_hiring (test_completer.CompleterTest) ... ok
    test_arg_limit (test_completer.CompleterTest) ... ok
    test_arg_user (test_completer.CompleterTest) ... ok
    test_arg_view (test_completer.CompleterTest) ... ok
    test_blank (test_completer.CompleterTest) ... ok
    test_command (test_completer.CompleterTest) ... ok
    test_completing_option (test_completer.CompleterTest) ... ok
    test_fuzzy (test_completer.CompleterTest) ... ok
    test_multiple_options (test_completer.CompleterTest) ... ok
    test_no_completions (test_completer.CompleterTest) ... ok
    test_option_freelance (test_completer.CompleterTest) ... ok
    test_option_hiring (test_completer.CompleterTest) ... ok
    test_option_user (test_completer.CompleterTest) ... ok
    test_option_view (test_completer.CompleterTest) ... ok
    test_subcommand (test_completer.CompleterTest) ... ok
    test_ask (test_hacker_news.HackerNewsTest) ... ok
    test_best (test_hacker_news.HackerNewsTest) ... ok
    test_format_comment (test_hacker_news.HackerNewsTest) ... ok
    test_format_index_title (test_hacker_news.HackerNewsTest) ... ok
    test_format_item (test_hacker_news.HackerNewsTest) ... ok
    test_format_markdown (test_hacker_news.HackerNewsTest) ... ok
    test_headlines_message (test_hacker_news.HackerNewsTest) ... ok
    test_hiring_and_freelance (test_hacker_news.HackerNewsTest) ...
    

    Do you know how to get unittest to print the errors and a stack trace?

    @matthiasbeyer haxor-news is broken on unstable

    opened by dotlambda 5
  • The latest pip version is breaking the design

    The latest pip version is breaking the design

    Pip version: 10.0.0 Python version: 3.6.5 && 2.7.14 Operating system: macOS 10.13.5

    Description: for dist in pip.get_installed_distributions(): AttributeError: 'module' object has no attribute 'get_installed_distributions'

    What I've run: pip.get_installed_distributions()

    question response-needed 
    opened by say2sankalp 4
  • Update latest monthly hiring post ids (June 2018)

    Update latest monthly hiring post ids (June 2018)

    Ask HN: Who is hiring? https://news.ycombinator.com/item?id=TBD

    Ask HN: Freelancer? Seeking freelancer? https://news.ycombinator.com/item?id=TBD

    Ask HN: Who wants to be hired? https://news.ycombinator.com/item?id=TBD

    If you'd like to contribute on a bite-sized issue, feel free to submit a pull request for next month's set of hiring post ids.

    Check out these PRs as a reference:

    • https://github.com/donnemartin/haxor-news/pull/23
    • https://github.com/donnemartin/haxor-news/pull/49
    • https://github.com/donnemartin/haxor-news/pull/64

    "Ask HN: Who wants to be hired?" isn't hooked up yet.

    enhancement help wanted 
    opened by donnemartin 4
  • Command for exiting 'haxor' terminal

    Command for exiting 'haxor' terminal

    Hi...

    I think it would be a good thing to have a command that can help exit from the haxor command line.

    Currently F10 is the key used for this purpose. However, in some terminals the key may be bound to some other function. Like in my case I am using the GNOME Terminal (3.6.2) that comes with Linux Mint. In this pressing F10 opens the file menu.

    Ctrl+C, exit, halt, quit don't work for quiting the haxor command line to get to the original command line. It would be great if such a functionality could be added.

    feature-request 
    opened by jashgala 4
  • Error in tests/run_test.py

    Error in tests/run_test.py

    I just ran the master and got this

    python tests/run_tests.py 
    ...................F.E........................................................
    ======================================================================
    ERROR: test_load_hiring_and_freelance_ids_invalid_url (test_config.ConfigTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/sankalp/Dev/haxor-news/tests/test_config.py", line 60, in test_load_hiring_and_freelance_ids_invalid_url
        os.remove('./downloaded_settings.py')
    FileNotFoundError: [Errno 2] No such file or directory: './downloaded_settings.py'
    
    ======================================================================
    FAIL: test_load_hiring_and_freelance_ids (test_config.ConfigTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/sankalp/Dev/haxor-news/tests/test_config.py", line 53, in test_load_hiring_and_freelance_ids
        assert self.hn.config.hiring_id != who_is_hiring_post_id
    AssertionError
    
    ----------------------------------------------------------------------
    Ran 76 tests in 7.678s
    
    FAILED (failures=1, errors=1)
    
    

    I need a good eye to understand whats wrong here!!

    duplicate enhancement 
    opened by say2sankalp 3
  • Changing the default colors

    Changing the default colors

    Hi,

    I am trying to configure the colors used by the haxor-news shell.

    It looks like you are using prompt_toolkit and pygmentize, but the style name seems to be hardcoded with "vim" as value. What is the intended method of configuring this setting?

    question 
    opened by kchr 3
  • Update README URLs based on HTTP redirects

    Update README URLs based on HTTP redirects

    Created with https://github.com/dkhamsing/frankenstein

    GitHub Corrected URLs

    | Was | Now | | --- | --- | | https://github.com/mitsuhiko/click | https://github.com/pallets/click |

    HTTPS Corrected URLs

    | Was | Now | | --- | --- | | http://codecov.io/github/donnemartin/haxor-news/branch.svg?branch=master | https://codecov.io/github/donnemartin/haxor-news/branch.svg?branch=master | | http://img.shields.io/license-apache-blue.svg | https://img.shields.io/license-apache-blue.svg |

    opened by ReadmeCritic 3
  • Need to sanitize comments

    Need to sanitize comments

    UnicodeEncodeError: 'charmap' codec can't encode character '\u200a' in position 14: character maps to <undefined> windows 7, using cmd and python 3.5

    while browsing comments, when reaching an unsupported character the entire screen fills up with a trace of the error

    bug 
    opened by pussinboot 3
  • Fix #167: Update latest monthly hiring post ids

    Fix #167: Update latest monthly hiring post ids

    Update bot values with February 2019 posts.

    Not sure where the value for "Ask HN: Who wants to be hired?" should be put?

    • the value is 19055164 for that
    opened by pahakalle 2
Releases(0.4.2)
  • 0.4.2(Apr 9, 2017)

    Changelog

    0.4.2 (2017-04-08)

    Bug Fixes

    • #94 - Update to prompt-toolkit 1.0.0, which includes a number of performance improvements (especially noticeable on Windows) and bug fixes.
    Source code(tar.gz)
    Source code(zip)
  • 0.4.1(May 30, 2016)

    Changelog

    0.4.1 (2016-05-30)

    Bug Fixes

    • #62 - Fix prompt-toolkit v1.0.0 hanging while autocompleting the hn view command. Revert back to prompt-toolkit v0.52. This bug only happens on Windows.
    Source code(tar.gz)
    Source code(zip)
  • 0.4.0(May 30, 2016)

    Changelog

    0.4.0 (2016-05-30)

    Features

    • #52 - Add exit and quit commands, which can be used instead of ctrl-d.
    • #53 - Allow clicking of urls in some terminals to open in a browser.

    Bug Fixes

    • #36 - Fix crash caused by Unicode comments on Windows.
    • #59 - Update to prompt-toolkit 1.0.0, which includes a number of performance improvements (especially noticeable on Windows) and bug fixes.
    • Fix some comments and docstrings.

    Updates

    • #48, #50 - Update latest monthly hiring post ids.
    • #56 - Update packaging dependencies based on semantic versioning.
    • Fix Config docstrings.
    • Update README:
      • Update intro
      • Add Hacker News discussion of haxor-news
      • Update comments discussion and examples
      • Update TODO
      • Fix urls based on redirects
      • Remove buggy Codecov graph
      • Add note about OS X 10.11 pip installation issue
    • Add Gemnasium dependencies management.
    • Update links in CONTRIBUTING.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.1(May 24, 2016)

Owner
Donne Martin
Tech Lead @facebook
Donne Martin
LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

Jannis Zahn 7 Jun 21, 2022
Detect secret in source code, scan your repo for leaks. Find secrets with GitGuardian and prevent leaked credentials. GitGuardian is an automated secrets detection & remediation service.

GitGuardian Shield: protect your secrets with GitGuardian GitGuardian shield (ggshield) is a CLI application that runs in your local environment or in

GitGuardian 1.2k Jan 06, 2023
Command line interface to watch your childhood shows in hindi and english, designed with python

Sweet dreams: Most of your childhood shows Command line interface to watch your

Not Your Surya 3 Feb 13, 2022
Proman is a simple tool for managing projects through cli.

proman proman is a project manager. It helps you manage your projects from a terminal. The features are listed below. Installation Step 1: Download or

Arjun Somvanshi 2 Dec 06, 2021
Official AIdea command line tool

AIdea CLI Official AIdea command line tool for https://aidea-web.tw. Installation Make sure you have installed both Python 3 and pip package manager.

AIdea 5 Dec 15, 2021
🖥️ A cross-platform modern shell.

Ergonomica WARNING: master on this repository is not the same as a stable release! Currently, this software is purely experimental, as I am cleaning i

813 Dec 27, 2022
A command line interface to interact with the Hypixel api allowing the user to get stats, leaderboards, etc

HyConsole is a way to get data on players and leaderboards from the Hypixel Minecraft server from the command line. Keep in mind I have no a

1 Feb 14, 2022
Arithmos cipher on CLI based

Arithmos Cipher CLI This is the CLI version of Arithmos Cipher. Install pip inst

LyQuid :3 1 Jan 16, 2022
A CLI application for storing contacts as a csv file written in Python.

Contacter A CLI application for storing contacts as a csv file written in Python. You can use this to save your contacts with a special relations tag

nostalgicnerdpenguin 1 Oct 23, 2021
A CLI Password Manager made using Python and Postgresql database.

ManageMyPasswords (CLI Edition) A CLI Password Manager made using Python and Postgresql database. Quick Start Guide First Clone The Project git clone

Imira Randeniya 1 Sep 11, 2022
Set of scripts & tools for converting between numbers and major system encoded words.

major-system-converter Set of scripts & tools for converting between numbers and major system encoded words. Uses phonetics instead of letters to conv

4 Aug 09, 2022
Skiller - With this payload you can control the target computer with (cmd)

Skiller - With this payload you can control the target computer with (cmd)

1 Jan 02, 2022
This is a tool for managing file notes through the command line

This is a tool for managing file notes through the command line

2 Jun 22, 2022
alternative cli util for update-alternatives

altb altb is a cli utility influenced by update-alternatives of ubuntu. Linked paths are added to $HOME/.local/bin according to XDG Base Directory Spe

Elran Shefer 8 Dec 07, 2022
texel - Command line interface for reading spreadsheets inside terminal

texel - Command line interface for reading spreadsheets inside terminal. Sometimes, you have to deal with spreadsheets. Those are sad times. Fortunate

128 Dec 19, 2022
commandline version of wordle game and my auto solver.

Wordle Machine (and Wordle Game) (in commandline) My implementation of the Wordle game (inspired by https://www.powerlanguage.co.uk/wordle/) and my in

Kevin Xu 11 Jan 03, 2023
Rdwcli - Car list cli app with python

Rdwcli - Car list cli app with python

Arie Twigt 1 Feb 02, 2022
A command line tool that creates a super timeline from SentinelOne's Deep Visibility data

S1SuperTimeline A command line tool that creates a super timeline from SentinelOne's Deep Visibility data What does it do? The script accepts a S1QL q

Juan Ortega 2 Feb 08, 2022
A simple command line dumper written in Python 3.

A simple command line dumper written in Python 3.

ImFatF1sh 1 Oct 10, 2021
Darkdump - Search The Deep Web Straight From Your Terminal

Darkdump - Search The Deep Web Straight From Your Terminal About Darkdump Darkdump is a simple script written in Python3.9 in which it allows users to

Josh Schiavone 264 Dec 30, 2022