-
Notifications
You must be signed in to change notification settings - Fork 322
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
Feature request: cd on exit #140
Comments
It's already possible, you can find some scripts (for posix shell or fish) in the repo for doing just that |
Aha, thank you. But that solution doesn’t seem to cover step 2?
… 18 feb. 2019 kl. 23:46 skrev Olivier Perret ***@***.***>:
It's already possible, you can find some scripts (for posix shell or fish) in the repo for doing just that
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@jocap We have shell commands which pauses the ui and use the underlying stdin/stdout/stderr for input and output so things can get confusing if we use stdout instead of a separate file though I haven't actually tried this. We don't have a separate command implemented for step 2 but maybe someone may have already come up with a clever solution that I haven't considered. My workaround for this case is simply to go back with |
I think a solution would be for |
@occivink That could work I guess. We can also add a separate command for this. In the meantime, I also thought about a workaround using marks as follows:
@jocap You can put this in your |
Olivier Perret wrote:
I think a solution would be for `quit` to take an optional return code, and in the wrapper script you would only `cd` if `lf` returned 0.
This is a good idea.
gokcehan wrote:
@jocap You can put this in your `lfrc` file. First command marks the inital directory with `-` key, and the second command assigns `Q` key to load `-` mark first before quitting.
And this is a nice workaround. Thank you!
|
These solutions are pretty neat. I added the following to my
Also added this to
Thanks! |
@nostdm You can also use |
Love that this feature is up for discussion. Any chance of it coming in a release? |
@Glench The workaround already seems to work so I don't think there is anything else we need to do about this. We should probably close this issue. |
So the workaround is this?
and it lets you execute the cd command to the current directory displayed in |
@Glench You also need |
Oh sorry, mispaste. But even with that I don't see the expected behavior of leaving my shell
|
@Glench Just to be clear, if you want to change to the last directory, you need to be using the script provided in |
@gokcehan I get random promts for
They are appear randomly, most noticably while launching |
I'm also having issues with the suggested mapping but it isn't related to |
okay, I got something working with the To be clear, what I was hoping for was the normal behavior of the Is this possible currently or a planned feature? |
@Glench You can play around with the mappings to get what you want. For example:
You can also define commands for this purpose. @freed00m @ranebrown I have been able to reproduce it once but I can't do it again. It seems like a random bug. I'm marking this issue as a bug in the meantime. |
Seems like it might be related to using
|
@ranebrown I wrote the above example from head head and you're right, there is a recursive mapping, so Regarding the bug, I still can't produce it using |
There was a race condition with |
Delay issues seems to be fixed. Thanks! |
This is currently broken, as marks are written to disk immediately (and appear to be automatically sourced after the marks file changes). So if I open two instances of lf from different directories, then, when I press q in the first one, it will change to the directory the second instance was launched in. |
The So, I think a better solution is still needed. |
I also tried replacing On the bright side, |
I think I solved the puzzle:
|
Good @ilyagr this also solves the problem I had when running multiple instances of lf simultaneously. In the meantime I worked around the problem by having lf write the directory the parent shell should cd into to a custom file descriptor, but now I can use |
Is there some additional step to have OLDPWD defined? I get this error: |
|
I use bash. It seems to be unset when a new shell is opened. Even if I ensure it is defined in the shell where I spawn lf it seems to not be set within lf. I'm guessing lf is using a fresh shell and not inheriting that variable. |
Perhaps you are using really old version of lf (before r22, where this seems to have been introduced), @ranebrown? If you enter |
I'm on version 27. I get the same unbound variable error with the echo. |
The workaround seems fine but you have to type lfcd instead of lf. Adding alias lf to lfcd creates an error
Maybe increasing FUNCNEST may fix the issue, but is there a workaround to this workaround? The same error comes up when renaming lfcd to lf in the lfcd.sh script |
@harishnkr You are getting an issue with infinite recursion. To solve it, change the |
Interesting, as processes spawned by shells inherit the environment
variables of their parents. Nevertheless, I would use a shell function
for starting lf like the `lfcd` from above.
|
@ilyagr Thanks! It worked without a problem. |
People keep running into an infinite loop and being confused. See gokcehan#140 (comment) and gokcehan#1043. This fixes the issues in `lfcd.sh` and `lfcd.fish`. For the other scripts, I'm not sure whether this issue exists or is fixable. One of the discussions above also suggested the need to document the key binding better.
People keep running into an infinite loop and being confused. See #140 (comment) and #1043. This fixes the issues in `lfcd.sh` and `lfcd.fish`. For the other scripts, I'm not sure whether this issue exists or is fixable. One of the discussions above also suggested the need to document the key binding better.
I think it would be nice to have the parent shell cd to the directory opened in lf on exit, similarly to what fff does.
There would be two components to this feature:
(The 'cancel' command would make it possible to quit lf without having the shell cd to the opened directory.)
fff achieves step 1 by writing to a file on disk, but I don't this really is necessary. Instead of to stdout, the user interface can be printed directly to the tty, leaving room in stdout for echoing the directory.
Thoughts?
The text was updated successfully, but these errors were encountered: