Package: terminal-leetcode
Terminal-LeetcodeTerminal-Leetcode is a terminal based leetcode website viewer.This project is inspired byRTV.March 22th UpdateAdd code submit function.After finishing your code, presssat quiz detail view to submit your code to leetcode.Add company tag support.You can company tag to terminal-leetcode home view column. The tag file is in JSON format which can be easilyedit and share. You can find tag file of Facebook from tags directory.RequirementsPython 3.7UrwidInstallationInstall with pip$ pip3 install terminal-leetcodeClone the repository$ git clone https://github.com/chishui/terminal-leetcode.git  
 $ cd terminal-leetcode  
 $ sudo python setup.py installFor UbuntuNeed to install lxml dependencies first on Ubuntu.apt-get install libxml2-dev libxslt1-dev python-devUsageTo run the program, inputleetcodein terminal$ leetcodeLoginOption 1This option will get your cookies from your browser and use those for any requests agains leetcode website. So
you need to sign in your account from your browser first. There may be some limitations, please refer to pycookiecheat
for itsdocumentationOn Mac for the first time use, it will pop up a window and ask to input password of your computer.Option 2 (No longer available)To login you need to create a config.cfg file in folder ~/.config/leetcode.Input your username and password in config.cfg as:[leetcode]
username=chishui
password=123456Then restart this program.Programming LanguageYou can set your programming language in config.cfg as:[leetcode]
........
language=Javato see default sample code in quiz detail view in your favorite language.Please make sure to use Leetcode supported programming languages and use the string exactly
the same as it appears in Leetcode.TagsYou can customize your "Tag" column by adding a json file named tag.json into ~/.config/leetcode folder.The format of tag.json is showed below:{
  "1" : ["F", "G"],
  "10" : ["F"],
  ......
}By adding this file, quiz 1 will have a "F" and "G" tag and quiz 10 will have a "F" tag.You can use this feature to add company tag on quizzes.I have added a "F" tag sample file in "tags" folder. You could try this file to see all "F" tag quizzes.Writing CodeTerminal-Leetcode allows you to open editor to edit default code you are viewing.You can set your code editing settings in config.cfg as:[leetcode]
........
ext=java # file extention
path=~/program/leetcode # code file directoryThen when you are in quiz detail view, presseto open editor to edit code sample.Code sample is saved into directory you set in config.cfg automatically with file name combined
with quiz id and file extension you set.Default editor is vim, you can setexport EDITOR=***to change editor. You can refer tothis articleto use Sublime Text as command line editor.Tmux SupportIf you're using Terminal-Leetcode inside of a tmux session, when you presse, current tmux window will be
splitted vertically and an editor is opened inside the new created tmux pane.
This feature could be turned on and off by config option in config.cfg as:[leetcode]
........
tmux_support=true/falseNote that when you pressein detail view,  all other panes in current tmux
window except for the detail pane will be closed before the new edit pane is
created, so that you can edit solution for another problem seamlessly without
manually exiting vim and closing the edit pane.Code SnippetTwo code snippets can be used when creating code file.You can create filesbeforeandafterin~/.config/leetcode/snippet. Code snippet inbeforewill be placed at the beginning of the code file. Code snippet in fileafterwill be placed at the end of
the code file.Like in C++, write#include <iostream>
#include <vector>

using namespace std;in filebeforeandint main() {
    Solution s;
}in fileafter, then you can view code of quiz (take quiz 123 for example) as:#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int maxProfit(vector<int>& prices) {
        
    }
};

int main() {
    Solution s;
}It becomes much easier to write your solution code and then test your solution.C++ SpecificIf you don't set language in config.cfg, default language is C++.If you set C++ as your programming language, when you open editor, a Makefile is created automatically, so
after you finish the code, you can usemakedirectly to compile your code.Controls:PressHto see help information.Pressupanddownto go through quiz list.Pressenterorrightto see a quiz detail, and pressleftto go back.PressRin quiz list view to retrieve quiz from website.PressPageUporPageDownto go to prev or next page.PressHomeorEndto go to the first or last quiz.Pressfin quiz list view to search quiz by id or title.Pressnin quiz list view to search next quiz with search text input before.In quiz detail view, pressnwill always create a new sample code file.Presstin quiz list view to add tag for quiz.Pressein quiz detail view to open editor to edit code.Pressdin quiz detail view to open discussion page in web browser.PressSin quiz detail view to open solutions page in web browser.Presssin quiz detail view to submit your code.Press1in quiz list view to sort quiz list by id.Press2in quiz list view to sort quiz list by title.Press3in quiz list view to sort quiz list by acceptance.Press4in quiz list view to sort quiz list by difficulty.Vim's moving keysh,j,k,l,ctrl+f,ctrl+bare supported.TODOTestSubmit codeUser loginQuiz list sortInstall with pipGet quiz default code interfaceContributeAll kinds of contributions are welcome.LicenceMIT