ThePrimeagen / .dotfiles

2.99k stars 303 forks source link

Suggestion: Fix tmux-sessionizer keybinding #64

Open opera-duanei opened 5 months ago

opera-duanei commented 5 months ago

Hey @ThePrimeagen! Just came from the frontend masters course. Couldn't stand that the

bindkey -s ^f "tmux-sessionizer\n"

binding appends to whatever is already on the input.

This seems to do the trick (on mac at least)

bindkey -s '^f' "^Qtmux-sessionizer\n"

Whatever was on the terminal before will be added back when you exit tmux

Couldn't find anywhere what ^q actually does, but it seems to remove the input, let you run one command and then add back the input!

wadegbow commented 4 months ago

Another method is to create an zsh nle (new line editor) widget, it's a bit more text but has the benefit of not actually typing out tmux-sessionizer into the terminal, which was bugging me.

example:

session-widget() { tmux-sessionizer }
zle -N session-widget
bindkey ^f session-widget

Edit: just fyi ^Q is running the zsh push-line widget, you could also use ^U kill-whole-line if you dont care about getting what you had typed back. More info: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html