Giter Club home page Giter Club logo

Comments (9)

gokcehan avatar gokcehan commented on August 16, 2024

@lenormf I need to check the code to see if this is possible. Is there a use case for this?

from lf.

lenormf avatar lenormf commented on August 16, 2024

I've implemented a bookmark command that works with numbers (like in ranger), and right now my binding is the following:

map b push :bookmark<space>

But I would like to simply bind a key to the bookmark command, and have the latter get the count. My case is not the most representative because bookmarks could also be letters (in which case my current implementation is clearly better), but maybe there's other things out there that could benefit from a count environment variable.

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

@lenormf It never occurred to me that we could implement bookmarks with commands. This could be interesting. In the meantime, I have looked at the code a little bit and there doesn't seem like an easy way to do this so it may take some time.

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

@lenormf I have been thinking about bookmarks. If we pass count variable as you suggested then I think we still won't be able to list available bookmarks to the user to choose from, am I right?

from lf.

lenormf avatar lenormf commented on August 16, 2024

My implementation stores the saved paths in files, so listing all the bookmarks is a easy as walking through all those files and displaying their contents.

The idea behind using counts is that I would be able to save/load a bookmark in just two keystrokes, as opposed to issuing the bookmark command with the bookmark name as parameter, and hitting enter. I managed to trim down the amount of keystrokes to a minimum with the following mapping, but using count would be the fastest way since I assume that bookmarks' names are numbers:

map b push :bookmark<space>

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

So there are two parts to a bookmark implementation. We need to be able to save the current directory as a bookmark (e.g. bookmark-save), and we should be able to load a bookmark when we need it (e.g. bookmark-load). I understand this may reduce keystrokes in the first part but we still need the second part. This can also reduce keystrokes in the second part but I can't think of a way to list bookmarks at the same time. So then users need to remember which keys they have saved their bookmarks which may be difficult.

I'm asking because I was thinking second part could be implemented as such. Assume bookmarks are saved in a file. When we run bookmark-load command, which could be bound to a key, we can print the list of bookmarks and wait for a keystroke. Depending on the keystroke we can change the directory with a remote command. It's tricky to read a single character in posix shell without an enter key but it's still possible (lf uses it for its "press any key" implementation).

Then the first part could also be implemented in a similar fashion. When a user run bookmark-save command, ui is paused and a message says something like push a key to assign a bookmark. Then we can save the current directory in the bookmark file. Pausing the ui may not be very desirable but at least it has the advantage to be able to use keys other than numbers.

from lf.

lenormf avatar lenormf commented on August 16, 2024

I only need a single command in my implementation, what would be bookmark-load in your explanation would do bookmark-save of the current directory if no prior bookmark was created with the given ID. I think it's more convenient that way, do you want to have two separate commands (map B bookmark-save; map b bookmark-load)?

This can also reduce keystrokes in the second part but I can't think of a way to list bookmarks at the same time

If you know how/where the bookmarks are stored, you also know which ones have been saved, don't you? Unless you meant there's no logical place where the code to display all the bookmarks would be triggered in an implementation where the ID is hit first?

In any case, I thought of using counts first because I thought it would be easy to add them to the shell environment, and they would allow access to bookmarks using max. 2 strokes. ranger uses alt based mappings, but I don't really like it, so counts seemed like a good deal when -similarly to ranger- I wanted my bookmarks to be single digits. I don't mind having a more interactive implementation as long as I don't have to hit too many keys (3 is borderline cumbersome for me, compared to how fast it was with ranger).

That also raises another question, is there any use for counts as a part of the environment? Should another issue dedicated to bookmarks be created, or should this one be renamed?

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

I don't mind having a single command or two commands for this purpose as long as it works.

I have now opened a new issue (#76) for bookmarks. Bookmarks were the original motivation for this feature. If we can implement bookmarks without this feature maybe we can leave this issue here with a low priority until another possible use case comes up.

from lf.

joelim-work avatar joelim-work commented on August 16, 2024

This is fixed in #1187 and can be closed.

@gokcehan I didn't realise this issue existed, otherwise I would have linked it in the PR so that it would automatically be closed.

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.