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

question: Is there a way i can output the last-dir-path to STDOUT #472

Closed
ghost opened this issue Sep 16, 2020 · 10 comments
Closed

question: Is there a way i can output the last-dir-path to STDOUT #472

ghost opened this issue Sep 16, 2020 · 10 comments

Comments

@ghost
Copy link

ghost commented Sep 16, 2020

No description provided.

@Provessor
Copy link
Contributor

How about:

lfcat () {
    tmp="$(mktemp)"
    lf -last-dir-path="$tmp" "$@"
    if [ -f "$tmp" ]; then
        cat "$tmp"
        rm -f "$tmp"
    fi
}

@ghost
Copy link
Author

ghost commented Sep 17, 2020

no. i want direct output to stdout. no temp file.

@Provessor
Copy link
Contributor

@qlcom you can't view the path this way but it does work in a script

lf -last-dir-path="/dev/stdout" "$@"

@ghost
Copy link
Author

ghost commented Sep 17, 2020

can't it have a option to just print it to stdout, like how fzf prints it's selection to stdout

@Provessor
Copy link
Contributor

@qlcom it could but it doesn't at the moment.

You probably want to change this into a feature request and try to convince someone to do it.

@ghost

This comment has been minimized.

@ghost ghost closed this as completed Sep 17, 2020
@gokcehan
Copy link
Owner

@qlcom The reason this is missing is that lf allows shell commands to use stdout while running. If you were to use lf in a pipe or subprocess, and run a shell command while it is running, things can get ugly. So I'm not sure if this is a good idea, though there are ways to do this as discussed above if you insist on doing this. fzf is a great tool that has proved itself useful with the simple unix IO model, though there are many programs for which this model falls short. Most editors for example don't implement this, and I don't think it makes them less unixy. Not everything is meant to be used in pipes or subprocesses.

In any case, I'm not strictly against adding such an option, though I think we should figure out a way to prevent the use of shell commands with such an option. If you like to see this feature, feel free to reopen this issue to track it, and I can mark it as enhancement. It's probably a good idea to drop the angry customer attitude though.

@ghost
Copy link
Author

ghost commented Sep 18, 2020

It's probably a good idea to drop the angry customer attitude though.

yeah, i was a little angry.

Thank you for your answer.

@ghost ghost reopened this Sep 18, 2020
@gokcehan
Copy link
Owner

Yet another workaround is to have a command like the following:

map q :{{
    $printf $PWD
    quit
}}

@Provessor
Copy link
Contributor

@gokcehan a note if you decide to work on this: my option in #472 (comment) would work as expected if the screen was closed before writing the directory path.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants