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

Support systems with nushell as the default shell #130

Closed
benjamin-voisin opened this issue Jun 24, 2024 · 10 comments · Fixed by #152
Closed

Support systems with nushell as the default shell #130

benjamin-voisin opened this issue Jun 24, 2024 · 10 comments · Fixed by #152
Labels
enhancement New feature or request

Comments

@benjamin-voisin
Copy link

I'm using neovim v0.10.0 and Yazi v0.2.5 on arch. I copied the install script on the Readme for Lazy.
When I try to launch yazi (with - or cw), the floating window appears but shows this error :

error: unexpected argument '>' found

Usage: yazi [OPTIONS] [ENTRY]

For more information, try '--help'.

[Process exited 2]
@benjamin-voisin benjamin-voisin changed the title Unable to launch yazi Error when launching yazi Jun 24, 2024
@mikavilpas
Copy link
Owner

Hi! Maybe the shell redirection isn't working correctly for you 🤔

Could you try setting log_level = vim.log.levels.DEBUG like in my config here (except don't comment it out like I have.

You can find the location of the log file by issuing :checkhealth yazi:

image

For me it prints out this:

[2024-06-24 19:09:56] DEBUG Opening yazi with the command: (yazi '/Users/mikavilpas/git/yazi.nvim' --local-events "rename,delete,trash,move,cd" --chooser-file "/var/folders/23/y7gf7hz129l56_83w_g49jl80000gn/T/nvim.mikavilpas/oL4In8/0" > "/var/folders/23/y7gf7hz129l56_83w_g49jl80000gn/T/nvim.mikavilpas/oL4In8/1")

Having done all this, do you get any errors if you run the yazi command in your shell? Any idea if anything could be wrong with that?

@benjamin-voisin
Copy link
Author

I get this :

[2024-06-24 17:17:07] DEBUG Opening yazi with the command: (yazi '/home/binj/Documents/file.txt' --local-events "rename,delete,trash,move,cd" --chooser-file "/tmp/nvim.binj/S177ju/0" > "/tmp/nvim.binj/S177ju/1")

And it doesn't launch in my shell. I'm quite sure that this is because I use nushell (and the > operator is not as in bash).
The command without the redirection :

yazi '/home/binj/Documents/file.txt' --local-events "rename,delete,trash,move,cd" --chooser-file "/tmp/nvim.binj/S177ju/0"

works in my shell without issues

@mikavilpas
Copy link
Owner

Okay, sounds like good progress. How have you set your neovim to use nushell?

What does nushell use for redirecting output to a file?

@benjamin-voisin
Copy link
Author

Nushell is my default shell for my whole user, so nvim uses it. After some tries, here is the working command to reproduce the same comportment:

yazi '/home/binj/Documents/file.txt' --local-events "rename,delete,trash,move,cd" --chooser-file "/tmp/nvim.binj/S177ju/0" out> "/tmp/nvim.binj/S177ju/1"

(It's juste out> instead of >)

I'm looking at ways to easily know which shell we are using, but I don't find anything very satisfying. Something like echo $SHELL but ofc in nushell it's echo $env.SHELL...

@mikavilpas
Copy link
Owner

I don't know how well supported nushell is is neovim. I googled around for a bit and sadly found almost no results.

There is :shellredir

						*'shellredir'* *'srr'*
'shellredir' 'srr'	string	(default ">", ">&" or ">%s 2>&1")
			global
	String to be used to put the output of a filter command in a temporary
	file.  See also |:!|.  See |option-backslash| about including spaces
	and backslashes.
	The name of the temporary file can be represented by "%s" if necessary
	(the file name is appended automatically if no %s appears in the value
	of this option).
	The default is ">".  For Unix, if the 'shell' option is "csh" or
	"tcsh" during initializations, the default becomes ">&".  If the
	'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta",
	"bash" or "fish", the default becomes ">%s 2>&1".  This means that
	stderr is also included.  For Win32, the Unix checks are done and
	additionally "cmd" is checked for, which makes the default ">%s 2>&1".
	Also, the same names with ".exe" appended are checked for.
	The initialization of this option is done after reading the vimrc
	and the other initializations, so that when the 'shell' option is set
	there, the 'shellredir' option changes automatically unless it was
	explicitly set before.
	In the future pipes may be used for filtering and this option will
	become obsolete (at least for Unix).
	This option cannot be set from a |modeline| or in the |sandbox|, for
	security reasons.

But this looks pretty confusing. In yazi's case both output streams (stdout and stderr) are needed separately, and this option seems to mix them into one in some cases. I don't feel comfortable using it as it doesn't give a guarantee of not breaking for some users.

It might be a good idea to change your neovim to use a traditional shell by default, and enable nushell for specific use cases that you care about. I don't know how this can be done.

@mikavilpas mikavilpas added the invalid This doesn't seem right label Jun 27, 2024
@mikavilpas
Copy link
Owner

I have an upcoming feature that might solve this. It gets rid of the problematic shell redirection logic entirely.

If you're willing to install yazi and ya from the currently latest source, you can try it out in #152

@mikavilpas mikavilpas added enhancement New feature or request and removed invalid This doesn't seem right labels Jul 9, 2024
@mikavilpas mikavilpas changed the title Error when launching yazi Support systems with nutshell as the default shell Jul 9, 2024
@mikavilpas mikavilpas changed the title Support systems with nutshell as the default shell Support systems with nushell as the default shell Jul 9, 2024
@benjamin-voisin
Copy link
Author

I tried it and it works perfectly !
Thank you ❤️

@mikavilpas
Copy link
Owner

Wow that's great 👍🏻👍🏻

I'm planning to merge that in this week, and will close this when that happens.

mikavilpas added a commit that referenced this issue Jul 10, 2024
* feat: support bulk renaming files in nightly yazi (opt-in)

This change is optional, and by default is not enabled for users.

To opt in, you need to do the following:
- install the latest `yazi` from source
- install the latest `ya` from source. `ya` is the standalone command
  line tool for yazi. You can read
  <sxyazi/yazi#914> for more information.
- set the new config option `use_ya_for_events_reading = true` (it's
  `false` by default for now)
- run `:checkhealth yazi` to verify that `ya` is found and that the
  healthcheck passes

Bulk renaming in yazi is done by
- selecting multiple files in yazi
- pressing `r` to rename the files. This will open `$EDITOR`, typically
  Neovim, inside yazi.
- The nested Neovim will display the selected file names, one per line.
  The user can then edit the names as needed.
- save and quit the nested Neovim instance. This will rename the files
  in yazi.

<https://yazi-rs.github.io/docs/configuration/keymap/#manager.rename>

---

Technical details for developers:

- in the future, once the next release of yazi is out, yazi.nvim may
  automatically use `ya` for reading events. This would then be the
  default behavior. `ya` may enable more advanced features in the
  future.
- `yazi` is now built from source in continuous integration
- the integration testing system, although perhaps innovative, is still
  taking shape. I believe in time it will stabilize, but I don't want to
  cement the design too much until the best structure becomes evident in
  time.

Closes #135, closes #130

* chore: always open cypress in e2e mode by default

* fixup! feat: support bulk renaming files in nightly yazi (opt-in)

* fixup! feat: support bulk renaming files in nightly yazi (opt-in)
@Ben-PH
Copy link

Ben-PH commented Jul 20, 2024

I reinstalled yazi using `cargo install --locked --git ...

While it was in the process of doing that, I reinstalled the nvim plugin, and got a "please install yazi" error as expected.

Once the install was done, I tried rerunning it and still got the same unexpected argument error pop up, but when I uncommented these lines in the config:

    -- enable these if you are using the latest version of yazi
    use_ya_for_events_reading = true,
    use_yazi_client_id_flag = true,

...it worked!

Hopefully the next person recreating my journey will scroll down to here and save themselves a touch of headache.

@mikavilpas
Copy link
Owner

Good stuff - glad you got it working. This will likely be the default behaviour once the next stable version of yazi comes out.

Right now we have to do this so everyone is not forced to install from source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants