Commit Graph

54 Commits

Author SHA1 Message Date
0af6c9fb24 zsh:keys: Fix override of fzf-cd-widget
This commit addresses a couple of issues:

1. fzf's `key-bindings.zsh` was sourced twice: Once in keys.zsh and once
   via the symlink in `external-plugins/`. Fix this by removing the
   source in `keys.zsh`.

2. The section about the fzf bindings in keys.zsh was a mess. Reorder
   and rewrite some comments to make it nicer.

3. My just added custom `fzf-cd-inplace-widget` does not work like this.
   Since `key-bindings.zsh` is sourced (was sourced again) after
   `keys.zsh`, my override is overridden itself by the default. I
   noticed and fixed this when I originally wrote and tested the
   function, but unfortunately I forgot the old `bindkey` commands in
   `keys.zsh`, which is why I now forgot about it and committed this
   erroneously. To fix this, bind the keys after sourcing
   `key-binding.zsh` in the newly added `fzf.key-bindings.config.zsh`.
   Additionally, move the widget definition as well to have everything
   at one place.

Fixes: 3cf445e739 (zsh:keys: Modify fzf's cd widget to be "in-prompt",
       2025-08-06)
2025-08-06 13:30:56 +02:00
3cf445e739 zsh:keys: Modify fzf's cd widget to be "in-prompt"
Currently, fzf's cd widget executes the cd command via accept-line, so
the command is also visible in the scrollback buffer. In contrast to
this, the cd-{forward,backward,up} suite changes the directory in-place,
without touching BUFFER, with an additional prompt redraw (one could say
"in-prompt"). Since I find this more appealing, overwrite the default
fzf widget with a custom one that has the same behaviour.
2025-08-06 12:30:35 +02:00
04ef69c021 zsh:rationalize-dots: Self-insert when replacing 2025-06-02 11:32:27 +02:00
0cb18dedef zsh:keys:cmd-on-enter: Switch until conditions
The requirement does not need to be executed if the idx wrapped around
already.
2025-03-26 00:51:19 +01:00
a9bd4585aa zsh:keys:cmd-on-enter: Take gs out of rotation
It's a bit annoying, ll is sufficient.
2025-03-26 00:50:25 +01:00
90b64a8603 zsh:keys: Remove duplicate cd-up definition
I forgot that this was already a thing before d961daf38 ("zsh:keys:
Change one dir up on `^U`") and missed that I only moved the function in
the file instead of creating it (the changes were lying around a bit).
2025-02-19 15:18:05 +01:00
d961daf384 zsh:keys: Change one dir up on ^U 2025-02-19 14:01:24 +01:00
a053efa93e zsh:keys: Mention AUTO_PUSHD for cd-{back,for}ward 2025-02-19 14:01:24 +01:00
9271350aab zsh:keys: Fix non-existing mapping of vi-kill-word
vi-kill-word does not exist. This change was lying around uncommitted
for ages now.

Fixes: 658797bda2 ("zsh:keys: Use `vi-` variants of navigation binds")
2024-11-06 13:56:27 +01:00
1ffd31d585 zsh:keys: Use (A) flag instead of hack to split LBUFFER
This way better solution using the `(A)` flag was given to me in the
zsh-users mailing list back in 2022 but I forgot to apply it.

See zshexpn(1):

> Convert the substitution into an array expression, even if it
> otherwise would be scalar.

Thanks Mikael!

Link: https://www.zsh.org/mla/users/2022/msg00668.html
2024-10-30 16:19:58 +01:00
442a1c1bdc zsh:keys: Make ^E work in vicmd too 2024-09-21 01:06:32 +02:00
35422b6fc4 fzf: Use bfs for ALT_C_COMMAND if available 2024-09-21 01:04:44 +02:00
97f00e1dd0 zsh:keys: Bind Ctrl-Shift-G to insert-shcwd 2023-11-20 19:38:13 +01:00
93467176f6 zsh:keys: Set sensible fzf args for go-shcwd
Copy arguments from shell/key-bindings.zsh of the fzf repo.
2023-11-20 19:27:17 +01:00
063b0559c9 fzf: Use fd as default command if installed 2023-06-23 17:08:57 +02:00
2114987106 zprofile: Fix non-export of FZF_DEFAULT_NO_RG
I never really noticed but `$FZF_ALT_C_COMMAND` was never set as
`$fzf_default_no_rg` would be empty. Because the variable was not
exported, the X session would not have it in it's environment.
2023-06-23 13:36:23 +02:00
072204c10c vim:keys: Discard stderr in FZF_CTRL_T_COMMAND
The prompt gets messed up on error messages from `find` (e.g. permission
errors). Discard them.
2023-04-11 22:49:15 +02:00
112b195d7b zsh:keys:TODO: Rather insert line on ^R 2023-02-27 14:11:43 +01:00
8e183a37bf zsh:keys: Bind ^U to cd ..
I do not use readline/emacs(?) mapping to clear the line with ^U anyways
as I have my beloved vim bindings.
2023-02-23 14:44:59 +01:00
a85d6c53c4 zsh:keys:go-shcwd: Only exclude exact $PWD
Fix the grep call to only exclude lines that are exactly the PWD instead
of containing it.
2023-02-23 14:44:59 +01:00
cf48efb4cb zsh:keys:go-shcwd: Do not suggest $PWD 2023-02-23 14:44:59 +01:00
86c3c1992a zsh:keys: Bind ^G to fuzzy shcwd 2023-02-23 14:44:59 +01:00
51a2ab77d7 zsh:keys: Extract redraw-prompt from cd-rotate
This makes it possible to use it in other bindings.
2023-02-23 14:32:54 +01:00
a7b975ae71 zsh:keys:cmd-on-enter: Check PREBUFFER as well
When typing a multi-line input (e.g. `echo foo\<CR>`) BUFFER can be
empty, even though the entire input is not.

Fix this by checking if PREBUFFER and BUFFER are empty.
2023-01-17 00:33:19 +01:00
5c1b67ddfc zsh:keys:cmd-on-enter: Don't place cmds in history 2022-12-29 18:09:20 +01:00
c41e395325 vim:keys: Use non-vi versions of backward delete
The `vi-` versions stop working after using `push-input` and trying to
edit the reappeared line.

This could be an upstream bug, as I can recreate it with `zsh -f`.
2022-10-21 17:33:57 +02:00
1930c8758f zsh:keys: Make shift-return act like return 2022-10-21 11:05:18 +02:00
350dd257f0 zsh:keys: Change ctrl-dot sequence to libtermkey 2022-10-21 01:25:36 +02:00
49e8e3a756 zsh:keys: Move through dirs like vims jumplist 2022-10-21 01:25:00 +02:00
286baf335f zsh:keys: Shift-{,Back}space should act like w/o 2022-10-21 01:23:43 +02:00
8651b073eb zsh:keys: Rely more on terminfo and use libtermkey
Introduce first mapping that follows the 'fixed keyboard input'[^1]
sequences. They allow the differentiation of all keys with each modifier
without gotchas like `tab` send the same sequence as `ctrl-i`.

[^1] - https://www.leonerd.org.uk/hacks/fixterms/
2022-10-21 01:22:52 +02:00
658797bda2 zsh:keys: Use vi- variants of navigation binds
They seem to be more consistent in doing the same/reversed thing when
triggering them backwards.
2022-10-21 01:22:51 +02:00
f7c43d5044 zsh:keys: Use ^s for vi-pound-insert
Change the binding from `^3` to `^s` and use vi-pound-insert as that one
does not accept the line.
2022-10-11 00:43:27 +02:00
bf7d9dbeeb zsh:keys: Use consistent notation for ASCII escape 2022-09-28 01:19:32 +02:00
14f615f5e1 zsh:keys:ratio_dots: Fix preview of first word
Previously the path preview misbehaved when typing dots on the first
shell word (e.g. executing a script in a parent directory). This
happened as the `(z)` parameter expansion flag does not expand to an
array rather a scalar. Because of that, `[-1]` returns the last
character.

Work around this issue by prepending LBUFFER with a dummy word, so that
it always contains at least 2 words.
2022-09-22 15:15:07 +02:00
9a5536c5c5 zsh:keys:rationalize_dots: Add comments 2022-09-22 15:14:38 +02:00
8792518bcb zsh:keys:rationalize_dots: Add .. scenario
Handle an LBUFFER value of `..` before pressing `.` by adding `/../`.
This scenario can only occur by deleting previously added segments or
using the new `default_dot` (See previous commit 72a8cfbcb ("zsh:keys:
Add normal `.` behaviour on `Ctrl-.`")).
2022-09-22 15:09:39 +02:00
72a8cfbcb0 zsh:keys: Add normal . behaviour on Ctrl-.
Having bound `.` to `rationalize_dots` makes typing paths with multiple
`../` segments super easy. This gets cumbersome in some situations
though.

Typing a path like `../.local` is only possible by either typing
`../.<BS><BS>local` (as it is expanded to `../../` on the third dot) or
`..//.local` which is not as annoying but somehow breaks completion on
further path segments.

Bind `Ctrl-.` (i.e. `^N`) to insert a normal dot.
2022-09-22 14:39:20 +02:00
181971c1db zsh: Add $fzf_default_no_rg
Move the fallback for $FZF_DEFAULT_COMMAND into the variable
fzf_default_no_rg that is always set.

This way FZF_ALT_C_COMMAND can reuse it instead of spawning a new shell
and messing with PATH.
2022-09-19 13:01:30 +02:00
1dab31ecda zsh:keys: Reuse the default fallback for FZF_ALT_C
Instead of implementing it twice, simulate a shell without ripgrep to
get the fallback of FZF_DEFAULT_COMMAND and modify it for use with
directories.
2022-09-19 12:52:00 +02:00
85b95dce37 zsh:keys: Set FZF_{CTRL_T,ALT_C}_COMMAND
Do not ignore hidden files.
2022-09-19 12:45:26 +02:00
6458a45461 zsh:keys: Bind ^W to backward-kill-word
For deleting a word while in the shell, I find it easier/faster to use
emacs bindings or Ctrl-Backspace and backward-kill-word instead of the
vi version.

In tmux, Ctrl-H (same esacape sequnce as Ctrl-Backspace) is used for
switching panes since f11b7fa56545 ("vim,tmux:plugs: Add
`vim-tmux-navigator`"), so I need to use Ctrl-W.

As that is bound to vi-backword-kill-word, rebind it to use the emacs
version.
2022-06-23 23:58:58 +02:00
6b2a03222b zsh:keys: Bind ^3 to pound-insert 2022-02-20 23:48:59 +01:00
fe8a656dfe zsh:keys:cmd-on-enter: Refactor for real cmd cycle
Refactor the function to keep an array of commands with requirements
that have to be met. Those commands are then cycled over a wrap around
index instead of the inflexible switch statement.
2021-12-29 18:58:45 +01:00
b6d2299444 zsh:keys:cmd-on-enter: Remove zle message print
It did nothing.
2021-12-29 17:33:33 +01:00
9f99ceafd4 zsh:keys:cmd-on-enter: Use ll instead of ls 2021-12-29 17:28:41 +01:00
2d65f187f4 zsh: Fix forgotten ZSH_CONF use
`$ZSH_CONF` was removed in af49c39ba3.
2021-07-15 02:44:04 +02:00
8890a4b604 zsh:keys: Remove fzf-hist functionality
Go back to a simpler approach, that the `fzf-history-widget` is only
called on <C-Up> and ^K in normal mode and <Up> & <Down> scroll through
the history normally.

The reason behind this change is that there were still some edge cases
in which the widget was wrongfully called when normal scrolling was
intended.
This change also makes it now possible that I can use commands in the
'surrounding' of a past command by first navigating to it with the
fzf-widget and then just using <Up> & <Down>.
2021-07-14 14:35:20 +02:00
48dc9ca561 zsh:keys:cmd-on-enter: Add reset on other command
If a command is normally executed CMD_ON_ENTER is reseted to `ls`.
Otherwise problems can occur when for example switching the directory to
a non-repo when CMD_ON_ENTER contains `gs`.
2021-03-09 15:47:09 +01:00
93225e2d66 zsh:keys:cmd-on-enter: Cycle between ls & gs too 2021-03-08 01:10:09 +01:00