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

Print selected folder/file to stdout when quitting gdu #85

Closed
pglira opened this issue Aug 5, 2021 · 4 comments
Closed

Print selected folder/file to stdout when quitting gdu #85

pglira opened this issue Aug 5, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@pglira
Copy link

pglira commented Aug 5, 2021

I'd like to cd into a selected folder when quitting gdu, e.g. to copy/move/delete large files. This would probably be a new feature of gdu, since I haven't found indications that this is currently possible.

@dundee
Copy link
Owner

dundee commented Aug 5, 2021

This is unfortunately not possible due to how process environments work. You cannot change environment of parent process.

I can implement the "Spawn shell in current directory" feature of ncdu though. Would that be benefitial for you?

@pglira
Copy link
Author

pglira commented Aug 5, 2021

IMO it is not necessary that gdu changes the directory itself. It would be sufficient if gdu prints the selected directory/folder to stdout after quitting. Changing directory would then be possible with:

cd $(gdu)

I think this would be much more flexible than the "Spawn shell in current directory" feature of ncdu.

(My use case would be to call gdu directly from vifm, navigate in gdu to a folder/file and on quitting goto that folder/file in vifm so that I can copy/move/delele files there.)

@dundee dundee added the enhancement New feature or request label Aug 17, 2021
@dundee dundee closed this as completed in 3035667 Aug 18, 2021
@pglira
Copy link
Author

pglira commented Aug 20, 2021

Thank you for implementing this!

However, I'm not able to use it as described above.

If I call simply gdu and quit with Q the last directory is printed to std out.

However, if I run cd $(gdu) the interactive mode of gdu does not start. Instead a file+folder listing with sizes is printed immediately to std out.

Example:

cd ~/Music
GDU_DIR=$(gdu) && echo $GDU_DIR
12.0 KiB /mp3 8.0 KiB /wav

@dundee
Copy link
Owner

dundee commented Aug 20, 2021

I am afraid this use case won't be possible. You cannot access stdin and stdout of the terminal in a sub-shell. Thus you cannot start interactive mode.

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

No branches or pull requests

2 participants