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

Keep working directory of broot process in sync with directory of its currently focused panel #813

Closed
WizardUli opened this issue Dec 28, 2023 · 7 comments · Fixed by #814
Labels
enhancement New feature or request

Comments

@WizardUli
Copy link

Hello. I'd like to suggest to keep broot's main process working directory in sync with the directory it is currently displaying just like the famous nnn file browser does (where you can literally just ls -la /proc/<pid of specific nnn process>/cwd to get the currently opened directory in that specific nnn instance).

This would have immediate benefits at least in:

  • Zellij (terminal multiplexer) where a new pane gets opened in the working directory of the process running in the currently focused pane.
  • Alacritty (terminal) where SpawnNewInstance command opens a new window in the working directory of the current TTY controlling process of the current window.

(Caveat: Zellij seems to be using CWD of the oldest still running process in the currently focused pane so nnn (or broot in the future) must be running in that pane directly without underlying shell like bash or fish (which is quite normal and common anyway in Zellij). Alacritty is more inteligent and uses CWD of the current TTY controlling process.)

@WizardUli WizardUli added the enhancement New feature or request label Dec 28, 2023
@WizardUli WizardUli changed the title Keep working directory of broot process in sync with directory of its current panel Keep working directory of broot process in sync with directory of its currently focues panel Dec 28, 2023
@WizardUli WizardUli changed the title Keep working directory of broot process in sync with directory of its currently focues panel Keep working directory of broot process in sync with directory of its currently focued panel Dec 28, 2023
@WizardUli WizardUli changed the title Keep working directory of broot process in sync with directory of its currently focued panel Keep working directory of broot process in sync with directory of its currently focused panel Dec 28, 2023
Canop added a commit that referenced this issue Dec 29, 2023
@Canop
Copy link
Owner

Canop commented Dec 29, 2023

I tried it: #814
It does work for Alacritty, but I fail to see other use cases right now.

@WizardUli
Copy link
Author

I think Open terminal here use-case is completely common in our universe and even Windows Explorer has it.|

Files manager which keeps their CWD in sync with their currently displayed folder:

  • nnn - already mentioned
  • ranger
  • lf

kitty - maybe the most popular terminal (with inbuilt multiplexer) - also supports opening a new pane/tab/window in CWD of the process currently controlling terminal via dedicated commands

  • new_tab_with_cwd
  • new_tab_with_cwd
  • new_window_with_cwd

these are not accidental commands since even their names' suffix _with_cwd is certainly not accidental.

I've been seeing this functionality for many years and came to think it is pretty standard but maybe these terminals&multiplexers and file-managers are pretty niche themself. Having it supported by broot would make opening new tab/pane/window in currently displayed folder in these terminals completely zero configuration.

Alternative is for user to define separate verbs like:

  • open a new Alacritty window here
  • open a new Zellij pane here
  • open a new Zellij tab here
  • open a new Kitty pane here
  • open a new Kitty window here
  • ....
    (and you can't automate it via one verb and context detection because you can't infer intention (tab vs pane vs window) neither support Zellij running in Alacritty etc..)

-Sales pitch over-

Hey, I really don't know how common it is. Broot is the first interactive file-manager-like (somewhat) application I encountered which does not sync its CWD. I can happily use your PR (haven't tried it yet btw.) as a patch during every and each broot upgrade. It's almost zero effort for me with Nix(OS)/home-manager.

Is it something which general audience may expect? IDK. Might there by any drawbacks? I don't think so but I really don't know. :(

@Canop
Copy link
Owner

Canop commented Dec 29, 2023

I'll do it.

Main question is should it be opt-in or opt-out (i.e. can it have a cost or negative side effects ?).

@Canop
Copy link
Owner

Canop commented Dec 30, 2023

I made it opt out.

@Canop
Copy link
Owner

Canop commented Dec 30, 2023

@WizardUli Can you try the PR before I merge it ?

@Canop
Copy link
Owner

Canop commented Dec 30, 2023

This feature is available with the just released 1.31.0

@AndydeCleyre
Copy link

Oh wow, thanks for this! I was curious if it obviated the need for the shell wrapper, and I think it doesn't, but it's very welcome for use within tmux, where opening a new pane/window/split/whatever always uses the broot-current folder.

I already had these related verbs, replacing two tmux binds just in the context of broot:

{
  key: f4
  shortcut: z
  external: tmux splitw
  set_working_dir: true
  leave_broot: false
}
{
  key: ctrl-t
  shortcut: tab
  external: tmux new-window -c {directory}
  set_working_dir: true
  leave_broot: false
}

And now I can get rid of them entirely, as using the tmux binds will work the same way.

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