Skip to content

Commit

Permalink
fzf buffer fix for browse (#122)
Browse files Browse the repository at this point in the history
* Update wd.sh

* Update wd.plugin.zsh

* Update README.md
  • Loading branch information
p1r473 authored May 12, 2024
1 parent 5dd02e9 commit b31e62a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ rm -f ~/.zcompdump; compinit
If you want to make use of the `fzf`-powered browse feature to fuzzy search through all your warp points, set up a keybind in your `.zshrc`:
```zsh
bindkey '^G' wd_browse
bindkey ${FZF_WD_BINDKEY:-'^B'} fuzzy_wd_widget
```
## Usage
Expand Down
9 changes: 5 additions & 4 deletions wd.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

eval "wd() { source '${0:A:h}/wd.sh' }"
wd > /dev/null
# Register the function as a Zsh widget
zle -N wd_browse
# Bind the widget to a key combination
bindkey '^G' wd_browse
zle -N wd_browse_widget
zle -N wd_restore_buffer
autoload -Uz add-zle-hook-widget
add-zle-hook-widget line-init wd_restore_buffer
bindkey ${FZF_WD_BINDKEY:-'^B'} wd_browse_widget
19 changes: 18 additions & 1 deletion wd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,23 @@ wd_browse() {
fi
}

wd_browse_widget() {
if [[ -e $WD_CONFIG ]]; then
wd_browse
saved_buffer=$BUFFER
saved_cursor=$CURSOR
BUFFER=
zle redisplay
zle accept-line
fi
}

wd_restore_buffer() {
BUFFER=$saved_buffer
CURSOR=$saved_cursor
saved_buffer=
saved_cursor=1
}
wd_list_all()
{
wd_print_msg "$WD_BLUE" "All warp points:"
Expand Down Expand Up @@ -371,7 +388,7 @@ wd_export_static_named_directories() {
fi
}

local WD_CONFIG=${WD_CONFIG:-$HOME/.warprc}
WD_CONFIG=${WD_CONFIG:-$HOME/.warprc}
local WD_QUIET=0
local WD_EXIT_CODE=0
local WD_DEBUG=0
Expand Down

0 comments on commit b31e62a

Please sign in to comment.