Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Command shortcode - #55

Merged
dfangl merged 9 commits into
mainfrom
feat/command-shortcode
Oct 7, 2021
Merged

dfangl merged 9 commits into
mainfrom
feat/command-shortcode

Conversation

@dfangl

@dfangl dfangl commented Oct 6, 2021 •

Copy link
Copy Markdown
Member

This command shortcode automatically makes the $ or # in front of commands unselectable.

How to use:

{{< command >}}
$ localstack start
# systemctl restart docker
{{< / command >}}

You can also pass parameters for the highlighting (like highlighting line numbers) to it, just like the highlight shortcode

{{< command "hl_lines=5" >}}
$ docker run \
  --rm -it \
  -p 4566:4566 \
  -p 4571:4571 \
  -e LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY:- } \
  localstack/localstack
{{< / command >}}

When to use it vs script tags with bash:

  • One liner commands like:
$ localstack start
  • Multiple commands in a single field:
$ localstack start
$ localstack status
  • Commands with matching output:
$ localstack start
Starting localstack...

When NOT to use it:

  • Things that could be considered a bash script, with comments.
    They should be using a bash code block, without prefixed $ or #s.
# this command will start LocalStack
localstack start &
# this command will wait for localstack to be started
for i in {}..
@dfangl
dfangl requested a review from alexrashed October 6, 2021 13:33
@dfangl
dfangl force-pushed the feat/command-shortcode branch from ca6dff4 to d0b6107 Compare October 6, 2021 16:16
@alexrashed
alexrashed force-pushed the feat/command-shortcode branch from f2f7ff3 to ffc805e Compare October 7, 2021 06:49
@alexrashed
alexrashed force-pushed the feat/command-shortcode branch from ffc805e to 024c0c2 Compare October 7, 2021 06:57

@alexrashed alexrashed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the one comment I posted (additional explanation / comments in the shortcode) it looks really nice!
I just compared main with this feature branch. Even though one might expect that it's not a big deal, it's really putting ease on ones nerve when you can just select the code without having to care about the prefixes. Also the formatting looks a little bit nicer (border).

Comment thread layouts/shortcodes/command.html Resolved
@dfangl
dfangl merged commit 7a81870 into main Oct 7, 2021
@dfangl
dfangl deleted the feat/command-shortcode branch October 7, 2021 09:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants