Last active
March 10, 2025 13:35
-
-
Save GeneralD/7255bc284e0a9589ee39effa834ac735 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
keybind_as_widget() { | |
local hash=$(echo $2 | md5) | |
local widget_name="__widget_$hash" | |
eval "function $widget_name() { $2; }" | |
zle -N $widget_name | |
bindkey $1 $widget_name | |
} | |
keybind_as_interactive_widget() { | |
local hash=$(echo $2 | md5) | |
local widget_name="__widget_$hash" | |
eval "function $widget_name() { echo \"$2\"; $2; zle reset-prompt; }" | |
zle -N $widget_name | |
bindkey $1 $widget_name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment