Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command shortcode #55

Merged
merged 9 commits into from
Oct 7, 2021
Merged

Command shortcode #55

merged 9 commits into from
Oct 7, 2021

Conversation

dfangl
Copy link
Member

@dfangl dfangl commented Oct 6, 2021

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 {}..

Copy link
Member

@alexrashed alexrashed left a comment

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).

layouts/shortcodes/command.html Show resolved Hide 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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants