Skip to content

Is it possible to have blocks of text in my cheat sheets #954

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

Open
gabriel-vanzandycke opened this issue Mar 4, 2025 · 7 comments · May be fixed by #962
Open

Is it possible to have blocks of text in my cheat sheets #954

gabriel-vanzandycke opened this issue Mar 4, 2025 · 7 comments · May be fixed by #962
Labels
new feature New feature or request

Comments

@gabriel-vanzandycke
Copy link

I like to use cheat sheets not only for command lines, but also for any block of code or text.

A naive example of cheat-block would be on how to git rebase:

1. fetch latest changes on main branch
2. call `git rebase <main-branch>` from the working branch
3. for each commit, solve conflict files and call `git add`
4. continue rebase with `git-rebase --continue`
5. once done, a force push may be required: `git push -f`

Another example would be to have a compact list of arguments for a command:

iostat
	-d     # The -d option is exclusive of the -c option and displays only the device utilization report.
	-k     # Display statistics in kilobytes per second instead of blocks per second.
	-t     # Print the time for each report displayed.
	-x     # Display  extended  statistics

I also have cheats like that don't correspond to commands that should be executed:

[ -b FILE ]	True if FILE exists and is a block-special file.
[ -c FILE ]	True if FILE exists and is a character-special file.
[ -d FILE ]	True if FILE exists and is a directory.
[ -e FILE ]	True if FILE exists.
...

And a last example:

!!     # execute last command.
!top   # execute the most recent command that starts with ‘top’ (e.g. !).
!top:p # displays the command that !top would run (also adds it as the latest command in the command history).
!$:p   # displays the word that !$ would execute.
!*     # displays the last word of the previous command.
!*:p   # displays the last word that !* would substitute.

The current implementation of navi doesn't allow for this type of cheat sheets.
A workaround is to split each line into multiple lines, with a common prefix, but lines can get messed-up in the fuzzy search. And it doesn't provide a compact result.

It would be great to have the possibility to have navi dump a block of text on stdout, such that it can be handily peaked for command composition right after.

@gabriel-vanzandycke gabriel-vanzandycke added the new feature New feature or request label Mar 4, 2025
@denisidoro
Copy link
Owner

I'm not sure I understand your use case entirely, but have you considered writing these blocks of text into a .txt, and then adding a navi snippet such as cat iostat_commands.txt?

@kqvanity
Copy link

support for multiline code-blocks would be great. I find it hard to maintain them after squashing them all in one line

@kit494way
Copy link
Contributor

@kqvanity Multiline code-block is already supported. See multiline-snippets.
You can also write cheats in Markdown with the extension .cheat.md, although this is not mentioned in the documentation.
In .cheat.md files, you can use three backtick code-blocks.

# multiline sample
```
echo hello \
    world
```

@gabriel-vanzandycke
Copy link
Author

The multiline snippets doesn't show as multiple lines in the fuzzy search table, it's Also, it doesn't seem possible to have the comment span multiple lines, is it ?
Thanks for the .md extension, I find it more intuitive to write multiple lines

@gabriel-vanzandycke
Copy link
Author

The main suggestion therefore becomes 2 requests:

  • can we have multiple lines of comments before a command or code-block ?
  • can we have the multiple lines code blocks (and multiple lines comments) displayed as multiple lines in the fuzzy search table ?

@kit494way
Copy link
Contributor

can we have multiple lines of comments before a command or code-block ?

We can write multiple lines of comments using ;. But this is not displayed in the fuzzy search table.

# hello world
; This is a metacomment.
; Not displayed in the fuzzy search table.
echo hello world

can we have the multiple lines code blocks (and multiple lines comments) displayed as multiple lines in the fuzzy search table ?

Although I think we cannot have multiple lines code blocks in the fuzzy search table, it can be configured to display it in the preview.
Try the configuration in the comment.

@gabriel-vanzandycke
Copy link
Author

gabriel-vanzandycke commented Mar 20, 2025

Sorry, I should have made myself clearer: I believe it would be very useful to have multiple lines of description.

And I believe it is possible to show multiple lines in the finder, as fzf already allows it (for the commands history):

Image

gabriel-vanzandycke added a commit to gabriel-vanzandycke/navi that referenced this issue Mar 20, 2025
gabriel-vanzandycke added a commit to gabriel-vanzandycke/navi that referenced this issue Mar 20, 2025
gabriel-vanzandycke added a commit to gabriel-vanzandycke/navi that referenced this issue Mar 20, 2025
gabriel-vanzandycke added a commit to gabriel-vanzandycke/navi that referenced this issue Mar 22, 2025
…locks with multiple lines (only fzf supported)
gabriel-vanzandycke added a commit to gabriel-vanzandycke/navi that referenced this issue Mar 22, 2025
gabriel-vanzandycke added a commit to gabriel-vanzandycke/navi that referenced this issue Mar 22, 2025
gabriel-vanzandycke added a commit to gabriel-vanzandycke/navi that referenced this issue Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants