acomagu / fish-async-prompt

Make your prompt asynchronous to improve the reactivity.
MIT License
412 stars 25 forks source link

leaves lots of tmpdirs behind #71

Closed sentriz closed 10 months ago

sentriz commented 11 months ago

hello, thanks for fish-async-prompt :+1:

i noticed my /tmp is full of 100s of files like tmp.XXX/PID_fish_right_prompt

i presume from code such as

    set -l func fish_right_prompt
            test -e $__async_prompt_tmpdir'/'$fish_pid'_'$func
            and cat $__async_prompt_tmpdir'/'$fish_pid'_'$func

should we expect to be cleaned up at some stage? or is that not implemented?

thanks :+1:

acomagu commented 11 months ago

We currently rely on the OS to clean up /tmp files. No cleanup mechanism in this plugin yet, but if this is causing issues, we'll consider adding this feature.

Is this causing any problems for you?

sentriz commented 11 months ago

would it be plausible do something like this? or does the tmpfile need to last longer than the current PID?

diff --git conf.d/__async_prompt.fish conf.d/__async_prompt.fish
index ebf970f..4d566a8 100644
--- conf.d/__async_prompt.fish
+++ conf.d/__async_prompt.fish
@@ -3,6 +3,10 @@ or exit 0

 set -g __async_prompt_tmpdir (command mktemp -d)

+function __async_prompt_tmpdir_cleanup --on-process-exit $fish_pid
+    rm "$__async_prompt_tmpdir"
+end
acomagu commented 10 months ago

@sentriz I added such code and it seemed to work, so I committed it. Thanks for the suggestion!

sentriz commented 10 months ago

thanks!