Comments (9)
@lenormf I need to check the code to see if this is possible. Is there a use case for this?
from lf.
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.
@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.
@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.
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.
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.
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.
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.
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)
- Sort_by function not work very well with hungarian letters HOT 2
- Chafa symbol preview error HOT 9
- lf image preview flickering HOT 5
- Duplicate icon
- Mouse buttons don't work
- Preview window colors HOT 14
- Yank path w/filename, filename, and file (As in Ranger) in Powershell HOT 6
- [QUESTION] Paste with overwrite for multiple files HOT 5
- Main Column Line Numbers Only HOT 8
- Outdated file information for recreated directories HOT 9
- directories have another font type HOT 2
- Feature request: highlighting of cursors when inactive HOT 3
- Feature request: add an lfrc switch to move duplicate copy suffixes at the beginning of filename. HOT 4
- `autoquit` should be enabled by default HOT 6
- how to use fribidi within lf.
- sixel preview writes out of bounds
- Broken characters of dir when I use `-print-last-dir` option / change drive option `/d` in `lfcd.cmd` HOT 3
- Issue with scrolling using alt key HOT 6
- Feature request: precalculate previews for files around the cursor HOT 3
- lf does not open terminal text editor when going right HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lf.