leo-arch / clifm

The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell.
https://github.com/leo-arch/clifm/wiki
GNU General Public License v2.0
1.29k stars 41 forks source link

cd_on_quit.sh doesn't work #247

Closed Juliaria08 closed 11 months ago

Juliaria08 commented 11 months ago

Describe the bug The script cd_on_quit.sh doesn't work, as the file $HOME/.config/clifm/.last isn't created by clifm

To Reproduce Steps to reproduce the behavior:

  1. Run 'clifm --cd-on-quit'
  2. Then run 'Q' inside clifm
  3. Then run cat $HOME/.config/clifm/.last and see error

Expected behavior Ethier the script cd_on_quit.sh somehow determines the profile, or clifm automatically creates .last inside the $HOME/.config/clifm/ folder, instead of only creating it in $HOME/.config/clifm/profiles/$<CLIFM_PROFILE>/

Desktop (please complete the following information):

Additional context Also update wiki page if the script is updated.

leo-arch commented 11 months ago

Hi @Juliaria08.

the file $HOME/.config/clifm/.last isn't created by clifm

Clifm does create this file itself at exit (as a symlink to ~/.config/clifm/profiles/PROFILE/.last, so that the profile name doesn't matter). I've reproduced all the steps you pointed out and see no error: the file is there. Whatever is the problem, it must be something else.

Btw, have you sourced the script as specified in the wiki? Have you executed clifm using the function name specified in the script (by default c)?

The complete procedure is as follows:

source /usr/share/clifm/functions/cd_on_quit.sh
c
# Once in Clifm:
Q
Juliaria08 commented 11 months ago

Yes, I ran that function as shown on the wiki I linked.and I ran c and then Q once there, I see no such symlink. If you have any info about how to troubleshoot inform me in a comment.

leo-arch commented 11 months ago

Made a clean install (clifm 1.13, from the AUR), using a clean config dir (~/.config/clifm) and nothing: everything works as expected. Let's try with inotifywait (from the inotify-tools package):

  1. Open a terminal and run: inotifywait -m -e create,delete ~/.config/clifm (let it running).
  2. On another terminal run clifm as usual: c and then Q.
  3. Go back to the first terminal, which should inform all files created and/or deleted in ~/.config/clifm. For example, here's the result I get:
$ inotifywait -m -e create,delete ~/.config/clifm
Setting up watches.
Watches established.
/home/user/.config/clifm/ DELETE .last
/home/user/.config/clifm/ CREATE .last

This means that the .last file was first deleted and then recreated at exit.

Juliaria08 commented 11 months ago

Oh wait sorry, seems like the file has now been created, weird. I did run it with the parameters I thought I run. I am sorry for anoying you. I got the following result:

$ inotifywait -m -e create,delete ~/.config/clifm
Setting up watches.
Watches established.
/home/user/.config/clifm CREATE .last

Which just told me that the file didn't exist before and that's weird for me, so ethier I didn't ever run the c command, (which I remember myself running a few hours ago), or for some I ran q instead of Q and changed my memory in the meantime.

leo-arch commented 11 months ago

Good to hear @Juliaria08! And don't worry, shit happens.

Remember that you can alias q to Q so that you don't need to run Q to activate cd-on-quit. Open the config file (F10) and add this line:

alias q='Q'
Juliaria08 commented 11 months ago

Remember that you can alias q to Q so that you don't need to run Q to activate cd-on-quit. Open the config file (F10) and add this line:

I did that, but probably I didn't test that my change worked. Thanks for helping 😃

leo-arch commented 5 months ago

Since version 1.16.6, Q (uppercase) isn't required anymore for the cd-on-quit function: the old plain q will do the trick.

mTvare6 commented 2 weeks ago

@leo-arch I didn't want to create a new issue for what I think is fixed, but does it actually work with ^d or can I only use q. Is there a workaround?

leo-arch commented 2 weeks ago

Hi @mTvare6! Thanks for reporting. With the latest commit cd-on-quit should work with Ctrl-D as well. Please give it a try and let me know if it works as expected.

leo-arch commented 6 days ago

Hey @mTvare6, can you confirm that cd-on-quit works now as expected?