$ npm install -g @hackmd/hackmd-cli
$ hackmd-cli COMMAND
running command...
$ hackmd-cli (-v|--version|version)
@hackmd/hackmd-cli/1.2.0 darwin-x64 node-v12.21.0
$ hackmd-cli --help [COMMAND]
USAGE
$ hackmd-cli COMMAND
...
hackmd-cli
operates on official HackMD instance(hackmd.io
) by default. If you want to use cli with a self-hosted CodiMD or a HackMD EE instance, you will need to configure hackmd-cli
by either environment variable or JSON configuration.
Set environment variable in your shell profile:
export CMD_CLI_SERVER_URL=https://my.codimd-domain.dev
Or in JSON file (~/.hackmd/config.json
):
{
"serverUrl": "https://my.codimd-domain.dev",
"enterprise": false
}
Set environment variable in your shell profile:
export HMD_CLI_SERVER_URL=https://my.hackmd-ee.domain
Or in JSON file (~/.hackmd/config.json
):
{
"serverUrl": "https://my.hackmd-ee.domain"
}
All available configurations are listed in the table below.
Config key | Environment Variable | Data Type | Example Value | Description |
---|---|---|---|---|
serverUrl |
HMD_CLI_SERVER_URL or CMD_CLI_SERVER_URL |
string |
https://my.codimd-domain.dev |
The instance URL |
cookiePath |
HMD_CLI_COOKIE_PATH or CMD_CLI_COOKIE_PATH |
string |
~/.hackmd/cookies.json |
File for storing login cookie states |
enterprise |
n/a | boolean |
true |
Set whether the instance is enterise version expclitly. This config can only be set in JSON based config. When providing server url with environment variable, enterprise will be automatically set by checking the env prefix(HMD or CMD ) |
n/a | HMD_CLI_ID or CMD_CLI_ID |
string |
me@codimd-domain.dev |
Login username/email |
n/a | HMD_CLI_PASSWORD or CMD_CLI_PASSWORD |
string |
dragon |
Login password |
Don't commit your login credentials!
hackmd-cli export [NOTEID] [OUTPUT]
hackmd-cli help [COMMAND]
hackmd-cli history
hackmd-cli import [FILE]
hackmd-cli list
hackmd-cli login
hackmd-cli logout
hackmd-cli teams
hackmd-cli whoami
Export note to local file or stdout(if the output_file param is omitted)
USAGE
$ hackmd-cli export [NOTEID] [OUTPUT]
OPTIONS
-h, --help show CLI help
--html
--md
--pdf
EXAMPLE
$ hackmd-cli export [--pdf|--md|--html] <note_id> <output_file>
See code: src/commands/export.ts
display help for hackmd-cli
USAGE
$ hackmd-cli help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
See code: @oclif/plugin-help
List history
USAGE
$ hackmd-cli history
OPTIONS
-h, --help show CLI help
-x, --extended show extra columns
--columns=columns only show provided columns (comma-separated)
--csv output is csv format [alias: --output=csv]
--filter=filter filter property by partial string matching, ex: name=foo
--no-header hide table header from output
--no-truncate do not truncate output to fit screen
--output=csv|json|yaml output in a more machine friendly format
--sort=sort property to sort by (prepend '-' for descending)
EXAMPLE
$ hackmd-cli history
ID Name
A58r8ehYTlySO94oiC_MUA Note1
EeNHDGocSTi70ytMMGQaaQ Note2
See code: src/commands/history.ts
Create a note from markdown file
USAGE
$ hackmd-cli import [FILE]
OPTIONS
-h, --help show CLI help
-t, --team=team team to use
EXAMPLE
$ hackmd-cli import /path/to/markdown/file.md --team=xxx
Your note is available at https://hackmd.io/note-url
See code: src/commands/import.ts
List owned notes or team notes (HackMD-only feature)
USAGE
$ hackmd-cli list
OPTIONS
-h, --help show CLI help
-t, --team=team team name
-x, --extended show extra columns
--columns=columns only show provided columns (comma-separated)
--csv output is csv format [alias: --output=csv]
--filter=filter filter property by partial string matching, ex: name=foo
--no-header hide table header from output
--no-truncate do not truncate output to fit screen
--output=csv|json|yaml output in a more machine friendly format
--sort=sort property to sort by (prepend '-' for descending)
EXAMPLE
$ hackmd-cli list
ID Name
A58r8ehYTlySO94oiC_MUA Note1
EeNHDGocSTi70ytMMGQaaQ Note2
See code: src/commands/list.ts
Login to HackMD/CodiMD server from CLI
USAGE
$ hackmd-cli login
OPTIONS
-h, --help show CLI help
-u, --id=id Login email/username
--ldap
EXAMPLE
$ hackmd-cli login
Enter your email: hello@hackmd.io
Enter your password: *******
Login as HMD successfully!
See code: src/commands/login.ts
Logout from CLI
USAGE
$ hackmd-cli logout
OPTIONS
-h, --help show CLI help
EXAMPLE
$ hackmd-cli logout
You've logged out successfully
See code: src/commands/logout.ts
HackMD Teams Command
USAGE
$ hackmd-cli teams
OPTIONS
-h, --help show CLI help
-x, --extended show extra columns
--columns=columns only show provided columns (comma-separated)
--csv output is csv format [alias: --output=csv]
--filter=filter filter property by partial string matching, ex: name=foo
--no-header hide table header from output
--no-truncate do not truncate output to fit screen
--output=csv|json|yaml output in a more machine friendly format
--sort=sort property to sort by (prepend '-' for descending)
EXAMPLE
$ hackmd-cli teams
Path Name
team1 Team 1
my-awesome-team My Awesome Team
See code: src/commands/teams.ts
Show logged in account info
USAGE
$ hackmd-cli whoami
OPTIONS
-h, --help show CLI help
EXAMPLE
$ hackmd-cli whoami
You are logged in hackmd.io as {YOUR NAME} [user-id]
See code: src/commands/whoami.ts
You can create a note by piping text stream to hackmd-cli
USAGE
$ hackmd-cli [COMMAND]
EXAMPLE
$ cat README.md | hackmd-cli
Your note is available at https://hackmd.io/note-url
MIT