Giter Club home page Giter Club logo

Comments (2)

gokberkgunes avatar gokberkgunes commented on August 16, 2024 1

Below line may partially do what you want. You should change zsh to bash, fish, sh or whatever shell program you prefer.

Exec=st -e sh -c "cd %u; lf; zsh"

This does not follow the directory where lf ends up. The directory of the shell will be the the downloaded directory.


After few more tries, figured out how to follow the path. Nevertheless, the command gets long and dirty. You may improve the command further by removing the temporary file and whatnot.

Exec=st -e sh -c "cd %u; lf -last-dir-path='/tmp/tmp.lfdir'; cd \"$(cat /tmp/tmp.lfdir)\"; zsh"

from lf.

ikyokara avatar ikyokara commented on August 16, 2024 1

@gokberkgunes
Awesome, it does indeed worked as I expected.
Yesterday, I was looking around and also found a solution to this. I created a script which included the lfcd() function then add lfcd "$@"; $SHELL at the end of the script. Call the script inside lf.desktop Exec=st -e /path/to/script %u which does exactly the same thing as

Exec=st -e sh -c "cd %u; lf -last-dir-path='/tmp/tmp.lfdir'; cd \"$(cat /tmp/tmp.lfdir)\"; zsh"

however, your version, it a lot shorter and doesn't require additional script and does exactly the same thing 👍

##### lf.sh
#!/bin/sh
lfcd () {
    tmp="$(mktemp)"
    # `command` is needed in case `lfcd` is aliased to `lf`
    command lf -last-dir-path="$tmp" "$@"
    if [ -f "$tmp" ]; then
        dir="$(cat "$tmp")"
        rm -f "$tmp"
        if [ -d "$dir" ]; then
            if [ "$dir" != "$(pwd)" ]; then
                cd "$dir"
            fi
        fi
    fi
}

lfcd "$@"; $SHELL

from lf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.