You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Without any modification of fzf, the CTRL-R output shows the correct history depending on the mode (i.e., global vs. PWD-specific). However, if I want to switch modes, I have to exit fzf, toggle the mode with ^G, then re-enter fzf. I'm wondering if it's possible to do this all within fzf.
I attempted to achieve this with various flavors of --bind='ctrl-g:execute(per-directory-history-toggle-history)' (NB: that function comes from the plugin [source]), but I get an error that per-directory-history-toggle-history cannot be found. Am I on the right track?
Followup inquiry
Lastly, to add one more layer of complexity that's specific to me, I wrap fzf-history-widget with my own simple logic to add a little indicator of the current history mode to the fzf prompt. I then bind this function to ^R, overwriting fzf's binding. The code shown below displays the correct indicator as intended:
This is where I tried to add the --bind bit, in hopes that ^G within fzf would not only toggle the mode and refresh the results, but also update the indicator:
fzf runs an external command with a new child shell process ($SHELL -c YOUR_COMMAND), and it looks like the zsh function is not available in the subshell. Perhaps the function is only defined in interactive sessions. Does $SHELL -ci per-directory-history-toggle-history work? If so, you can start trying something like become($SHELL -ci \"per-directory-history-toggle-history; fzf-history-widget-with-dynamic-history-mode-indicator\").
function per-directory-history-toggle-history() { ... }
function per-directory-history-toggle-history-widget() { # wrapper function
per-directory-history-toggle-history
}
autoload per-directory-history-toggle-history-widget
zle -N per-directory-history-toggle-history-widget
bindkey -M vicmd "^G" per-directory-history-toggle-history-widget
FZF_CTRL_R_OPTS="--bind='ctrl-g:become($SHELL -ci \"per-directory-history-toggle-history\")'"
The hope was that making making the wrapper function the widget and keeping the original function not a widget would allow fzf to call it directly. But I still got exactly the same error!
per-directory-history-toggle-history:zle:11: can only be called from widget function
man fzf
)Info
Sorry to blow up your issues lately. I love how deep you can take things with
fzf
if suitably motivated!Inquiry
I use the wonderful
per-directory-history
plugin in Zsh. Using it,^G
will toggle between history files, either global or PWD-specific.Without any modification of
fzf
, theCTRL-R
output shows the correct history depending on the mode (i.e., global vs. PWD-specific). However, if I want to switch modes, I have to exitfzf
, toggle the mode with^G
, then re-enterfzf
. I'm wondering if it's possible to do this all withinfzf
.I attempted to achieve this with various flavors of
--bind='ctrl-g:execute(per-directory-history-toggle-history)'
(NB: that function comes from the plugin [source]), but I get an error thatper-directory-history-toggle-history
cannot be found. Am I on the right track?Followup inquiry
Lastly, to add one more layer of complexity that's specific to me, I wrap
fzf-history-widget
with my own simple logic to add a little indicator of the current history mode to thefzf
prompt. I then bind this function to^R
, overwritingfzf
's binding. The code shown below displays the correct indicator as intended:This is where I tried to add the
--bind
bit, in hopes that^G
withinfzf
would not only toggle the mode and refresh the results, but also update the indicator:But when I add in
--bind='...'
, openfzf
with^R
, and hit^G
, it fails:I'm quite confident that this should be possible, but I can't quite figure it out. Any assistance @junegunn?
The text was updated successfully, but these errors were encountered: