Skip to content

Latest commit

 

History

History
156 lines (114 loc) · 4.34 KB

advanced.md

File metadata and controls

156 lines (114 loc) · 4.34 KB
layout title
default
Advanced Topic

Auto login

Leetcode.com is restricting only one session alive in the same time, which means if you login same account otherwhere, the existing login session will be expired immediately. This will greatly harm your experience since you have to re-login again and again among different sessions.

The good news is leetcode-cli will help a lot on this by trying re-login transparently and automatically without interrupting your current work whenever it detects your current session is expired. To enable this feature you could add following in your config then login again:

{
	"autologin": {
		"enable": true
	}
}

NOTE: once enabled, your PASSWORD will be persisted locally for further using, so PLEASE be careful to ONLY enable this on your OWN computer for the sake of security!

Bash Completion

Copy .lc-completion.bash to your home directory, and source it in .bashrc (Linux) or .bash_profile (MacOS).

$ cp .lc-completion.bash ~
$ echo "source ~/.lc-completion.bash" >> ~/.bashrc
$ source ~/.bashrc

$ leetcode list --<tab>
--help     --keyword  --query    --stat

NOTE: it might become slower in bash with this enabled, personally I would NOT suggest to use it...

Cache

The local cache folder (.lc/) is in your home directory, e.g.

$ ls -a1 ~/.lc/

.user.json                      # your account info
problems.json                   # problems list
1.two-sum.algorithms.json       # specific problem info

NOTE: Normally you don't need dig into the folder to manipulate those files. Use cache command instead.

Configuration

Create a JSON file named .lcconfig in your home directory, e.g.

$ cat ~/.lcconfig

{
	"auto_login": {
		"enable": false
	},
	"code": {
		"editor": "vim",
		"lang": "cpp"
	},
	"color": {
		"enable": true,
		"theme": "default"
	},
	"icon": {
		"theme": ""
	},
	"network": {
		"concurrency": 10
	},
	"plugins": {}
}

Here are some useful settings:

  • autologin:enable to enable auto login feature, see Auto Login.
  • code:editor to set editor used to open generated source file.
  • code:lang to set your default language used in coding.
  • color:enable to enable colorful output.
  • color:theme to set color theme used in output, see Color Theme.
  • icon:theme to set icon them used in output.
  • plugins to config each installed plugins, see Plugins.

NOTE: Normally you don't need dig into the folder to manipulate those files. Use config command instead.

Example

Config for github.js and cpp.lint.js plugins:

{
	"plugins": {
		"github": {
			"repo": "https://github.com/skygragon/test",
			"token": "abcdefghijklmnopqrstuvwxyz"
		},
		"cpp.lint": {
			"bin": "~/bin/cpplibt.py",
			"flags": []
		}
	}
}

Color Theme

You can choose to use colorful output or not.

  • --color to enable color.
  • --no-color to disable it.

Or use configuration setting to avoid typing it repeatedly, see color:enable.

When color is enabled, you can choose your favor color theme as well, see color:theme.

Following are available themes:

  • blue
  • default
  • dark for night.
  • orange
  • pink for girls.

Of course you can create your own themes if you like, please see colors folder in the source code.

Example

$ cat colors/default.json
{
    "black":   "#000000",
    "blue":    "#0000ff",
    "cyan":    "#00ffff",
    "green":   "#00ff00",
    "magenta": "#ff00ff",
    "red":     "#ff0000",
    "white":   "#ffffff",
    "yellow":  "#ffff00"
}

Log Level

  • -v to enable debug output.
  • -vv to enable trace output.
    • Will print detailed HTTP requests/responses.

Plugins

You can easily introduce more features by installing other plugins form third parties. Here lists the avaible 3rd party plugins at the moment:

Feel free to try out the plugins above. Or you can develope your own plugins to enrich leetcode-cli's functionalities.