denisidoro / navi

An interactive cheatsheet tool for the command-line
Apache License 2.0
14.93k stars 498 forks source link

ctrl-G include cheats in current folder #848

Closed qsh-zh closed 7 months ago

qsh-zh commented 1 year ago

Is your feature request related to a problem? Please describe.

Thank you for developing such an incredible tool like navi. I utilize it on a daily basis.

However, I have noticed that navi does not currently support including cheats from the current folder. I believe this feature would be highly beneficial. For instance, I create cheatsheets for various projects, encompassing tasks such as building, testing, and deployment. Currently, I have to manually make note of them and copy-paste whenever needed. Yet, if navi could include cheatsheets from the current folder or a specific folder dedicated to project-related cheatsheets, it would greatly simplify research and task execution.

I notice I can use --path in the terminal. However, I do not know how to do it with the shell widget.

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context

I am a zsh user.

phanirithvij commented 7 months ago

I am interested in this too, project level cheats. Would be very useful.

denisidoro commented 7 months ago

You can edit the code for the widget.

For example, instead of adding source "$(navi widget bash)" to your .bashrc file, you can:

  1. run navi widget bash > my_custom_navi_widget.bash
  2. edit the recently created file
  3. add source my_custom_navi_widget.bash to your .bashrc file

As for 2, you're probably interested in replacing the line

local -r replacement="$(_navi_call --print --query "$last_command")"

by

local -r replacement="$(_navi_call --path YOUR_CUSTOM_PATH --print --query "$last_command")"

To make it look for cheats in the current directory, you can use --path "$PWD"

phanirithvij commented 4 months ago

Did it as

eval "$(navi widget bash | sed 's/--print/--print --path \"\$PWD\"/g')"
eval "$(navi widget zsh | sed 's/--print/--print --path \"\$PWD\"/g')"
navi widget fish | sed 's/--print/--print --path "$PWD"/g' | source

Need to figure out a way to bind another keybind for this, I got used to ctrl+g for global.