diff options
author | Gautham Warrier <gautham.r.w@gmail.com> | 2020-10-27 23:31:52 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-27 19:01:52 +0100 |
commit | f0cc2bea79cac4ddce47062b5bd8795b10950f05 (patch) | |
tree | 0a33fb624743644b0eadff9a5155ee46197c8968 /src/init/starship.zsh | |
parent | b9c096bd56a2663599170081552307baf54370ef (diff) |
fix(zsh): Ensure existing keymap change functions are not overriden (#1826)
Diffstat (limited to 'src/init/starship.zsh')
-rw-r--r-- | src/init/starship.zsh | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/init/starship.zsh b/src/init/starship.zsh index 5ecb33d12..a01844bd6 100644 --- a/src/init/starship.zsh +++ b/src/init/starship.zsh @@ -54,13 +54,27 @@ if [[ -z ${preexec_function[(re)starship_preexec]} ]]; then fi # Set up a function to redraw the prompt if the user switches vi modes -zle-keymap-select() { +starship_zle-keymap-select() { starship_render zle reset-prompt } +## Check for existing keymap-select widget. +local existing_keymap_select_fn=$widgets[zle-keymap-select]; +# zle-keymap-select is a special widget so it'll be "user:fnName" or nothing. Let's get fnName only. +existing_keymap_select_fn=${existing_keymap_select_fn//user:}; +if [[ -z ${existing_keymap_select_fn} ]]; then + zle -N zle-keymap-select starship_zle-keymap-select; +else + # Define a wrapper fn to call the original widget fn and then Starship's. + starship_zle-keymap-select-wrapped() { + ${existing_keymap_select_fn} "$@"; + starship_zle-keymap-select "$@"; + } + zle -N zle-keymap-select starship_zle-keymap-select-wrapped; +fi + STARSHIP_START_TIME=$(::STARSHIP:: time) -zle -N zle-keymap-select export STARSHIP_SHELL="zsh" # Set up the session key that will be used to store logs |