Warp icon indicating copy to clipboard operation
Warp copied to clipboard

Support bindkeys

Open juliogarciag opened this issue 3 years ago • 42 comments

Describe the bug

Right now, Warp just ignores the user's bindkeys and they don't do anything.

Please upvote if you want us to honor them

juliogarciag avatar Dec 17 '21 04:12 juliogarciag

After taking a deeper look, it seems bindkey doesn't work yet. Is that something scheduled to be tackled soon?

juliogarciag avatar Dec 17 '21 16:12 juliogarciag

@juliogarciag CC'ing @charlespierce as he's working on custom keybindings and this falls under that umbrella!

elviskahoro avatar Dec 17 '21 19:12 elviskahoro

are there plans to do left option as ESC+ instead of Meta? I use ESC+. which is insert-last-word on zsh all the time and I just get ≥ regardless of whether Left Option Key is Meta is enabled $_ is my current workaround. Also might be for bugs but using actual ESC+. doesn't seem to work, so I'm guessing it's just a feature of Zsh Line Editor that isn't implemented at all

elviskahoro avatar Dec 21 '21 17:12 elviskahoro

Same problem to me, and bindkey does not work for zsh autosuggestions.

# zsh auto suggestions
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
bindkey '^k' autosuggest-accept
bindkey '^j' autosuggest-execute

linux-china avatar Jan 06 '22 18:01 linux-china

From:

  • #248

Describe the bug

Try putting the below in the ~/.zshrc

bindkey "^j" history-search-forward

To Reproduce

No response

Expected behaviour

No response

Screenshots

https://share.getcloudapp.com/7KuE7w6K

Operating System

No response

OS Version

No response

Additional context

No other bindkey seems to present an issue

elviskahoro avatar Jan 12 '22 19:01 elviskahoro

From @hardselius via:

  • #589

Describe the bug

I have the following snippet in my .zshrc

resume() {
  fg
  zle push-input
  BUFFER=""
  zle accept-line
}
zle -N resume
bindkey "^Z" resume

It serves as a "toggle" for programs running in the terminal, e.g vim.

To Reproduce

Steps to reproduce:

  1. Add the snippet to .zshrc
  2. Open vim
  3. Press ^Z to move vim to the background
  4. Press ^Z again and nothing happens.

Expected behaviour

In this case, I expect ^Z to bring my process back to the foreground, instead I have to manually run fg.

Screenshots

No response

Operating System

MacOS

OS Version

12.1

Additional context

No response

elviskahoro avatar Jan 12 '22 19:01 elviskahoro

It's very convenient to be able to use META-f or META-b to go forward and backward a word at a time in the terminal. Also, META-. to retrieve the last word used in the previous command. Would love to be able to have the option key bound to META rather than needing to use ESC.

psbanka avatar Jan 24 '22 19:01 psbanka

@psbanka is "Left option key is meta" on for you? Mac Menu > File Screen Shot 2022-01-24 at 2 46 46 PM

elviskahoro avatar Jan 24 '22 19:01 elviskahoro

Oh, wow, that's great, @elviskahoro , thank you! The last place I expected to find that was under the File > menu.

psbanka avatar Jan 24 '22 19:01 psbanka

@psbanka There's room to improve our discoverability. Where did you look for it? I'll see if we can get it added there, you're definitely not the first to ask!

elviskahoro avatar Jan 24 '22 20:01 elviskahoro

Zsh history expansion does not work

From @r-thomson

Describe the bug

Zsh's history expansion does not work in Warp (v0.2022.02.21.08.55.stable_00). It seems to work correctly in the stock Terminal app.

To Reproduce

  1. Type a history designator, e.g. !999
  2. Press tab

Expected behaviour

Element 999 (shown in history) should be inserted in-place.

Screenshots

No response

Operating System

MacOS

OS Version

12.2.1

Additional context

Here's my dotfiles, if it helps

elviskahoro avatar Feb 25 '22 04:02 elviskahoro

Sorry for necrobumping this thread, but is there a plan / ETA for supporting bindkeys?

This is a deal-breaker to me, in particular.

denisidoro avatar Mar 10 '22 12:03 denisidoro

I love the direction Warp is going (eg https://github.com/warpdotdev/Warp/discussions/625) but limiting the user to Warp-native solutions is too strict.

I myself have a plethora of fzf-based-autocompletions (cf https://github.com/warpdotdev/Warp/issues/149) which, in my case, are much more evolved than what Warp currently offers.

I'd really like to use Warp as my daily driver because of its other features (eg blocks) but not being able to do what a vanilla Terminal + zsh shell can offer has prevented me from switching.

denisidoro avatar Mar 10 '22 12:03 denisidoro

Lack of support for any zsh keybindings is really a deal breaker for me using Warp. It's also just painfully inelegant. Zsh has a whole system for managing keybindings, which I've invested it, and Warp just throws that away. Even when there's a zsh keybinding defined that doesn't overlap with a Warp binding it still doesn't pass the event along. This also means that little tweaks on default zsh keybindings can't be changed.

To use an example, I redefine some basic keybindings like this so that things like Ctrl-K (kill-line) integrates with the system pasteboard. Warp just ignores my Ctrl-K keybinding and does the zsh default kill-line, but without my customization the killed line doesn't end up in the system pasteboard. This uncanny valley of support is quite frustrating.

edit: Also I think the lack of bindkey support could use a separate github issue clearly describing it. The main post of this issue doesn't mention keybindings, and I think that's a feature that can stand on its own. (It's also unlikely Warp would address all the missing features mentioned in this issue at the same time)

varenc avatar Apr 08 '22 18:04 varenc

I found a partial workaround: Once in Warp, just run zsh again, embedding a zsh session in the already existing zsh session. This results in you losing most all special Warp features, but then all of zsh's features will re-appear. It sort of just turns Warp into speedy standard terminal emulator like all the others. This doesn't make sense for me but someone who daily drives Warp and occasionally needs some unsupported zsh feature might find this hack useful.

My custom keybinding on Ctrl-K still doesn't work, but other custom bindings do, as well my own history searching method. Could make sense for occasional use. ¯_(ツ)_/¯

varenc avatar Apr 09 '22 18:04 varenc

I use the zsh-autosuggestions plugin. It allows you to configure an autosuggest-execute hotkey, which I've configured to Ctrl-P. This works in iTerm2, but no Warp. This makes every auto-suggestion two key presses now, Ctrl-F to "accept autosuggestion" and then Enter to execute it. I'd like a shortcut to do both.

elviskahoro avatar Apr 15 '22 07:04 elviskahoro

I found a partial workaround: Once in Warp, just run zsh again, embedding a zsh session in the already existing zsh session. This results in you losing most all special Warp features, but then all of zsh's features will re-appear. It sort of just turns Warp into speedy standard terminal emulator like all the others. This doesn't make sense for me but someone who daily drives Warp and occasionally needs some unsupported zsh feature might find this hack useful.

My custom keybinding on Ctrl-K still doesn't work, but other custom bindings do, as well my own history searching method. Could make sense for occasional use. ¯_(ツ)_/¯

Well played, sir, lol.

Yeah this is annoying eh, seems like a big miss. I can see how the embedded fuzzy search on command history would reduce my need to use fzf for that specific use case. But as you said there is so much more than just fuzzy searching your command history (directories, files, etc.)

Hopefully they can find a solution for this, the terminal is a phenomenal piece of tech otherwise.

robbienohra avatar Apr 21 '22 01:04 robbienohra

Most of the comments are about bindkeys, so I'm going to change this title + description to be about bindkeys.

I made https://github.com/warpdotdev/Warp/issues/1514 to keep the original issue description

I'm really surprised there aren't more upvotes on this, because I hear a lot of anecdotal feedback about bindkeys, so changing the name in case it's confusion

zheng avatar Jun 16 '22 21:06 zheng

Either support for bindkey or a warp-feature to create bindings to custom commands is indeed dearly missed.

I just want to add, that currently, the Warp docs mention that you can use zshrc to create custom keybindings.

You can use the .zshrc file to customize behavior like: (...) It can also be used to set up key-bindings, and scripts that will automatically execute when a new instance of Zsh is launched.

However, this is not the case as long as there isn't support for bindkeys yet, so the docs are a bit misleading here.

chrisgrieser avatar Nov 18 '22 20:11 chrisgrieser

I found a partial workaround: Once in Warp, just run zsh again, embedding a zsh session in the already existing zsh session.

just tried because default fzf bind CTRL+T (fuzzy search files in directory) do not working. Running tmux session also working it drop default warp features and left it as "normal terminal".

And also left alt as meta actually started to work. in default warp looks like there are none influence even if i switch it in settings left/right ALT+C still print some weird symbol.

oiwn avatar Nov 19 '22 08:11 oiwn

Is this on anyone's radar? This is a deal breaker or me as I use a great plugin to fish that provides me with history + timestamps of command executions.

Gorthog avatar Jan 23 '23 10:01 Gorthog

Just giving this a friendly bump and a 👍 since it's something I'd love in Warp 🙏 🙏

izuzak avatar Mar 28 '23 06:03 izuzak

I think I have the same problem mentioned by anyone else, but I use bash instead of zsh. I noticed that Warp ignores the ~/.inputrc file and the bind command from Bash. I think is the same problem of the zsh.

So, I'm just leaving a little bit more context and a friendly thumbs up to this issue. This is the only reason that I didn't drop iTerm2 completely.

squiter avatar Jun 12 '23 21:06 squiter

Hey Folks thanks for commenting. As for right now although Warp doesn't support ~/.inputrc or bindkey, it does have ~./.warp/keybindings.yaml which you can use to bind keyboard shortcuts to existing Warp features/actions. Learn more about it here: https://docs.warp.dev/features/keyboard-shortcuts#custom-keyboard-shortcuts

I want to set realistic expectations that for this feature, we'd have to revamp significantly the way Warp's input editor works so it may be a while before we have any traction. Any updates to this we'll post here!

dannyneira avatar Jun 15 '23 15:06 dannyneira

@dannyneira how would this help in a case like:

bindkey '^f' fzf

I can't override the default keymap because (as far as I understand the implementation) I have to use a predefined action where as I want to execute a binary (i.e. fzf):

"<WHAT-GOES-HERE?>": ctrl-f

Integralist avatar Jun 16 '23 08:06 Integralist

@Integralist Yeah in this case we're currently not able to bind keyboard shortcuts to binaries or scripts. You're best to go with an alias in your rc file for quick access to (i.e.alias f=fzf). The current implementation of keybindings.yaml is only for existing features/actions in Warp.

dannyneira avatar Jun 16 '23 18:06 dannyneira

Hey Folks thanks for commenting. As for right now although Warp doesn't support ~/.inputrc or bindkey, it does have ~./.warp/keybindings.yaml which you can use to bind keyboard shortcuts to existing Warp features/actions. Learn more about it here: https://docs.warp.dev/features/keyboard-shortcuts#custom-keyboard-shortcuts

I want to set realistic expectations that for this feature, we'd have to revamp significantly the way Warp's input editor works so it may be a while before we have any traction. Any updates to this we'll post here!

Can there be some sort of helper script that converts my .zshrc to a slimmed down .zshrc and auto-populates the .keybindings file and whatever else warp uses? Or at the least, ignores unsupported things instead of refusing to work entirely?

Divide-By-0 avatar Jul 08 '23 06:07 Divide-By-0

As fresh user of Warp, I hit this issue. I cleared default key binding of ^r and put the bindkey '^f' fzf in my .zshrc. But it does not work. Any ideas how to tackle with this? Otherwise, I'll think about to change my default terminal app...

My use case is to combine: Warp + Atuin: https://github.com/atuinsh/atuin (Currently impossible, I think)

Dentrax avatar Aug 11 '23 16:08 Dentrax

@Dentrax You are correct that it isn't possible to bind a key to an app like fzf. We'd have to explicitly build support for this into Warp's Input Editor, since it's native

elviskahoro avatar Aug 16 '23 01:08 elviskahoro

This is a shame, I was about to adopt Warp but this is making me reconsider.

I have the following functionality defined in my fish config, which allows me to easily switch directories.

function cd_with_fzf
  cd $HOME && cd (fd -t d | fzf --preview="tree -L 1 {}" --bind="space:toggle-preview" --preview-window=:hidden) && echo $PWD && tree -L 2
end

bind \co cd_with_fzf

As bind doesn't work, I cannot use it. And there doesn't seem to be way to invoke custom functions with the Warp keybindings (only native keybinds).

Would be happy to see this implemented, I don't necessarily care about bind perse, but I just need a way to invoke custom functions using keybindings.

Although it feels like the optimal design should simply support native features that are provided by the underlying shell. In this case, first simply support the features of the underlying shell, before adding gimmicky stuff on top.

Edit: Actually I do care about bind, as I would prefer my fish shell configuration to remain cross compatible amongst different terminal emulators. Although adding another custom keybind to execute custom functions inside of Warps configuration would solve the issue usability wise. But best case scenario would be if bind simply works out of the box, with the potential of overlapping keybinds amongst bind and Warp. Which a user would then simply have to figure out himself. I'm okay with clearing a Warp keybinding to allow for 'room' to use the bind configured keybind.

hyperfocus1337 avatar Sep 07 '23 17:09 hyperfocus1337