Closed Syphdias closed 10 months ago
I feel like we had this discussion once before in the context of p10k but I cant find the corresponding issue.
Found the issue where we talked about it: https://github.com/romkatv/powerlevel10k/issues/72
I'm going to add a new widget similar to z4h-cd-down
that will display previous directories. Sort of like persistent cd
history, similar to z
. The last visited directory will always be the first in the list, so you'll be able to hit the widget's shortcut and then Enter.
Would that work for you?
P.S.
Functions and parameters that start with -z4h
or _z4h
are internal. Don't use them. If necessary, I can add z4h redraw-prompt
or something like that.
I'm going to add a new widget similar to
z4h-cd-down
that will display previous directories. Sort of like persistentcd
history, similar toz
. The last visited directory will always be the first in the list, so you'll be able to hit the widget's shortcut and then Enter.Would that work for you?
I think z
is similar to autojump
and jumps to recently visited places but is more trimmed towards most often visited. What you describe sounds better that what I want and what I was planing. :joy:
[...] and then Enter
Or tab (zstyle ':z4h:new-cd-widget' fzf-bindings 'tab:down'
)
Functions and parameters that start with
-z4h
or_z4h
are internal. Don't use them. If necessary, I can addz4h redraw-prompt
or something like that.
I expected as much. I'll wait for the new widget which will probably satisfy my needs. :wink:
The widget is currently blocked on finding a new keybidning for it. I'm open to changing some of the existing bindings if that'll help.
For context, right now on PC cd
widgets are bound to Alt+Arrow and on Mac to Shift+Arrow. They use all four arrows. How can a new cd
widget fit in there? Or maybe one of the existing widgets should be dropped or modified?
Left and right are so close together you can probably not scrap one without the other. I guess z4h-cd-up
is the least useful? Can you combine two arrows? like Alt+Left+Right?
At some point we discussed to support Alt+Up
while you are in Alt+Down
, I think it can help here. Here's my proposal:
Alt+Left/Right
(as today).Alt+Down
, and in there you can either go up with Alt+Up
, or go down just using filter in fzf. This way, Alt+Up
itself (not inside Alt+Down
) becomes available for a new widget.Alt+Up
(bound to the new widget) and you get fzf
with most frequently used foldersIMO Alt+Up is the most useful of the bunch. I don't want to lose it.
I think I'll add a new key to get started. Perhaps Alt+C as a mnemonic for cd
. In there future there also might be Alt+D and Alt+F for inserting directories and files in the command line (fetched from history).
- If you want to navigate to a completely different, frequently visited place, you use
Alt+Up
(bound to the new widget) and you getfzf
with most frequently used folders
I like the idea of combining it with another arrow key. But I would argue for combining it with Alt+Right and Alt+Left.
In the case of just having opened a new terminal there is nowhere to go previous or next except previously visited places.
fzf
with the most recent directories.For the cases where you already have something in the "cd history stack". I'd argue that it would be worth sacrificing or blurring the lines a little bit.
If you are in the most recent directory (no Alt+Left used yet) and you use Alt+Right, open a fzf
with the most recently visited directories. This would include the entire history stack, of course, but also other directories visited in other terminal sessions (maybe even open ones). To loop around you would press Alt+Right again to leave fzf
again an be back at ~
. Also Alt+Left would quit the fzf
in case you overshot from navigating to the most "right" directory.
Example:
Single cd
s into "Projects", "the-project", ~/Downloads
, unzipped/folder
. The imaginary stack would look like this and could be traversed by Alt+Left and Alt+Right:
$most-recent-directory # from old session or ~/Downloads/unzipped/folder
~ # 10
~/Projects
~/Projects/the-project
~/Downloads
~/Downloads/unzipped/folder
$fzf
# GOTO 10
Going down with Alt+Left, going up with Alt+Right.
This idea is quite complicated which could lower UX due to being complicated. Maybe it can be improved.
I've attempted to provide something along the lines of what's been discussed here. Please see https://github.com/romkatv/zsh4humans/issues/35#issuecomment-848940481.
This has been done a long time ago. Alt-R is the default binding for a new widget called :z4h:fzf-dir-history
. There is a way to configure it so that it can be rebound to Alt-Down without losing the original functionality of that key combo. See https://github.com/romkatv/zsh4humans/blob/master/tips.md#current-directory.
Hey, I'm trying to add some additional functionality (that is probably only useful for me) to
z4h-cd-back
and I found-z4h-redraw-prompt
in-z4h-cd-rotate
.Can I use
-z4h-redraw-prompt
or is there a public function for redrawing the prompt. I feel like we had this discussion once before in the context of p10k but I cant find the corresponding issue.The "probably only useful to me" background: I used to split my terminal emulator tilix which made it possible to use vde magic to get a new prompt in the same directory as the old terminal.
Nowadays I usually open new terminals via i3wm. I lose the vde features by doing that and to be honest most of the time I don't need to be in the same directory. I'd like to have the option to switch to it quickly though. So my two step idea:
This "something" could be
my-z4h-cd-back
which isz4h-cd-back
unless there is a recent "mark", then it jumps to that AND needs to redraw the prompt (thus the question)