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

modify the default chooser to use just --show to preview #1539

Merged
merged 5 commits into from
Jan 28, 2023

Conversation

fzdwx
Copy link
Contributor

@fzdwx fzdwx commented Jan 27, 2023

Overwrite CHOOSER_DEFAULT: fzf -> fzf --preview 'just --show {}'

image

@casey casey enabled auto-merge (squash) January 27, 2023 19:55
Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

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

This looks good! It looks like the tests are failing though.

auto-merge was automatically disabled January 28, 2023 03:24

Head branch was pushed to by a user without write access

@fzdwx
Copy link
Contributor Author

fzdwx commented Jan 28, 2023

Ok, test case has been fixed.

  1. invoke_error_function update regex
  2. default use --chooser fzf

@casey casey enabled auto-merge (squash) January 28, 2023 08:20
@casey casey disabled auto-merge January 28, 2023 08:21
@casey casey enabled auto-merge (squash) January 28, 2023 08:22
@casey casey merged commit 5f9ac39 into casey:master Jan 28, 2023
@fzdwx
Copy link
Contributor Author

fzdwx commented Jan 28, 2023

Cool !

@casey
Copy link
Owner

casey commented Jan 28, 2023

Merged! Thank you for the PR!

@lyderic
Copy link

lyderic commented Jun 3, 2023

It's nice. Unfortunately, it doesn't work if the justfile is called something else than 'justfile' :-(

For example:

just --justfile foo --choose

doesn't display the recipes in the right pop-up window, but:

error: No justfile found

Note: This is the same behaviour for shebang just scripts (i.e. scripts starting with '#!/usr/bin/env -S just --justfile')

Is there a workaround? Maybe a way to default to the old, plain fzf behaviour without --preview, when using --justfile or a just shebang script. I tried setting the environment variable CHOOSER_DEFAULT as follows:

$ CHOOSER_DEFAULT=fzf just --justfile foo --choose

but it didn't help.

Many thanks,
L.

Steps to reproduce:

$ just --version
just 1.14.0
$ just --init
Wrote justfile to `/dev/shm/justfile`
$ just --choose
# above command works, I can see the 'default' recipe in the right hand side fzf window
$ mv -v justfile foo
renamed 'justfile' -> 'foo'
$ just --justfile foo --choose
# this latter command doesn't work (see screenshot)

Screenshot from 2023-06-03 09-47-52

@Qeole
Copy link
Contributor

Qeole commented Dec 11, 2023

Unfortunately, it doesn't work if the justfile is called something else than 'justfile'

Also reported in #1638

Qeole added a commit to Qeole/just that referenced this pull request Dec 12, 2023
The default chooser is fzf, and we pass it a command to generate the
preview with "just --show" from the recipe name. This has been working
well as long as we rely on the default justfile available in the
directory, given that the preview command can find it too. However,
passing "--chose" alongside "--justfile" to select a specific file
results in the preview command not being able to find the right justfile
to process.

To address this issue, we turn the const string defining the preview
command into a function that takes the internal representation of the
justfile as an argument, and updates the preview command with the right
file.

Fixes: 5f9ac39 ("Use `just --show` in default chooser (casey#1539)")
Qeole added a commit to Qeole/just that referenced this pull request Dec 12, 2023
The default chooser is fzf, and we pass it a command to generate the
preview with "just --show" from the recipe name. This has been working
well as long as we rely on the default justfile available in the
directory, given that the preview command can find it too. However,
passing "--chose" alongside "--justfile" to select a specific file
results in the preview command not being able to find the right justfile
to process.

To address this issue, we turn the const string defining the preview
command into a function that takes the internal representation of the
justfile as an argument, and updates the preview command with the right
file.

Fixes: 5f9ac39 ("Use `just --show` in default chooser (casey#1539)")
Suggested-by: Casey Rodarmor <casey@rodarmor.com>
Qeole added a commit to Qeole/just that referenced this pull request Dec 12, 2023
The default chooser is fzf, and we pass it a command to generate the
preview with "just --show" from the recipe name. This has been working
well as long as we rely on the default justfile available in the
directory, given that the preview command can find it too. However,
passing "--chose" alongside "--justfile" to select a specific file
results in the preview command not being able to find the right justfile
to process.

To address this issue, we turn the const string defining the preview
command into a function that takes the internal representation of the
justfile as an argument, and updates the preview command with the right
file.

Fixes: 5f9ac39 ("Use `just --show` in default chooser (casey#1539)")
Suggested-by: Casey Rodarmor <casey@rodarmor.com>
Qeole added a commit to Qeole/just that referenced this pull request Dec 12, 2023
The default chooser is fzf, and we pass it a command to generate the
preview with "just --show" from the recipe name. This has been working
well as long as we rely on the default justfile available in the
directory, given that the preview command can find it too. However,
passing "--chose" alongside "--justfile" to select a specific file
results in the preview command not being able to find the right justfile
to process.

To address this issue, we turn the const string defining the preview
command into a function that takes the internal representation of the
justfile as an argument, and updates the preview command with the right
file.

Fixes: 5f9ac39 ("Use `just --show` in default chooser (casey#1539)")
Suggested-by: Casey Rodarmor <casey@rodarmor.com>
Qeole added a commit to Qeole/just that referenced this pull request Dec 13, 2023
The default chooser is fzf, and we pass it a command to generate the
preview with "just --show" from the recipe name. This has been working
well as long as we rely on the default justfile available in the
directory, given that the preview command can find it too. However,
passing "--chose" alongside "--justfile" to select a specific file
results in the preview command not being able to find the right justfile
to process.

To address this issue, we turn the const string defining the preview
command into a function that takes the internal representation of the
justfile as an argument, and updates the preview command with the right
file.

Fixes: 5f9ac39 ("Use `just --show` in default chooser (casey#1539)")
Suggested-by: Casey Rodarmor <casey@rodarmor.com>
Qeole added a commit to Qeole/just that referenced this pull request Dec 13, 2023
The default chooser is fzf, and we pass it a command to generate the
preview with "just --show" from the recipe name. This has been working
well as long as we rely on the default justfile available in the
directory, given that the preview command can find it too. However,
passing "--chose" alongside "--justfile" to select a specific file
results in the preview command not being able to find the right justfile
to process.

To address this issue, we turn the const string defining the preview
command into a function that takes the internal representation of the
justfile as an argument, and updates the preview command with the right
file.

Fixes: 5f9ac39 ("Use `just --show` in default chooser (casey#1539)")
Suggested-by: Casey Rodarmor <casey@rodarmor.com>
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.

4 participants