0

I am currently using yazi as a TUI file manager, and one thing I wanted to do was set it up with my terminal emulator in a multi-pane view to have the file manager and a command line synchronized.

Essentially, if I move into a new directory in yazi, the other pane, with another shell running, would also move to the new directory. If I wanted to open a file from yazi, it would open in the other pane/shell.

I know I can write to a different shell using something like <command xyz> > /proc/<pid>/fd/1, but it doesn't seem to let me actually execute the commands.

I know yazi can spawn subshells, and I was thinking one possibility is to connect to the subshell in the other pane, but I'm really unsure of how to connect a terminal emulator to an existing shell. I use WezTerm, which can do multiplexing, but I don't think that would allow me to connect to the subshell, which has a valid PID and /dev/pts/<N>

EDIT: As requested, usage examples.

Scenario 1 - Navigating directories

In this example, as I move through directories in yazi, the other pane will live update the PWD. So, if I default (in both) to ~, then moving to documents in yazi will cause my prompt to go from ~ to ~/documents, following the directory in yazi. I don't expect the reverse to occur, where changing directories in the shell pane changes directories in yazi, but changing them in yazi would still, always change them in the shell pane

Scenario 2 - Editing files

In this example, when "opening" a file with a terminal application, like nano, rather than replacing the yazi TUI until I close nano, nano would open in the shell pane to facilitate editing there

Scenario 3 - Running commands requiring sudo

In this example, we see a limitation where yazi doesn't do too well with commands that require the use of sudo, so executing commands directly in the shell pane act as they typically would in a shell

13
  • 4
    "I know I can write to a different shell" - no, that command does not write to that other shell. It writes to that other terminal, with the shell seeing absolutely nothing of it. Synthesizing input to that shell (e.g. pretending that you typed into the terminal) is tricky, and is nowadays being deprecated / removed for security reasons.
    – egmont
    Commented Mar 10 at 7:51
  • You should take a look at Terminator and possibly other tiling terminals that allow to broadcast your keypresses into multiple terminals.
    – egmont
    Commented Mar 10 at 7:52
  • I don't know yazi, but this sounds a lot like you would want more something like the split-screen interface of good-ole mc, as copied by very many TUI file managers. Either yazi can do the same, or you should be looking into extending it. Commented Mar 10 at 10:03
  • @egmont, are you sure, since the PID that is listed under /proc/<pid>/fd/1 is for the shell (fish, for me), not the terminal emulator (WezTerm). It appears the output is going to stdout, as if the remote shell sent it, rather than stdin, but the terminal emulator PID isn't involved
    – Hari
    Commented Mar 11 at 0:01
  • What steps do you perform when you get that /proc/<pid>/fd/1? If you check the shell's stdout then you get the shell's stdout, obviously. Most likely its stdin is also this same device, /dev/pts/<something>. But if you write to it, you write to the terminal, not the shell's input. You ask me if I'm sure, well not only I am very sure, but also you yourself have clearly said that this is the behavior you're experiencing.
    – egmont
    Commented Mar 11 at 6:03

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.