Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show tips when history is used #15

Open
mamiu opened this issue May 7, 2021 · 3 comments
Open

Don't show tips when history is used #15

mamiu opened this issue May 7, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@mamiu
Copy link

mamiu commented May 7, 2021

I usually use the history a lot. (E.g. the up arrow key or CTRLR from fzf)

But when using the history I don't want to see the tips.

Is that already possible and if so how?

@mamiu mamiu added the enhancement New feature or request label May 7, 2021
@gazorby
Copy link
Owner

gazorby commented Jun 17, 2021

Hi @mamiu!

Currently the plugin doesn't remember how abbreviations are triggered, so it's not possible for now.

I'm also interested in this feature, I'll take a look at it when I have some time.

@mamiu
Copy link
Author

mamiu commented Jun 17, 2021

@gazorby Ok get it. Thanks for taking care of it.

I just played around right now and found a workaround which works, but is probably not the best solution.

In the fish_user_key_bindings.fish file add a wrapper for the history-search-backward special input function which sets the __abbr_tips_used variable to 1 before calling the history-search-backward function. Then adjust all keybindings that use the history-search-backward function so that they use the wrapper instead.

# history-search-backward wrapper for the fish-abbreviation-tips plugin
function __abbr_tips_history_backward
    set -g __abbr_tips_used 1
    commandline -f history-search-backward
end

# user defined key bindings
function fish_user_key_bindings
    bind \e\[A __abbr_tips_history_backward # arrow up key
    # If you use other key bindings that use the history-search-backward function make sure they also call the custom __abbr_tips_history_backward function
end

@doubledup
Copy link

This also affects custom keybindings that add a command that has an abbreviation. eg. I use \co to open my editor, passing the contents of the line as arguments:

set -x EDITOR 'nvim'
# ...
abbr nv "$EDITOR"
# ...
bind \co "commandline -i ' $EDITOR '; commandline -f backward-kill-word beginning-of-line yank execute"

But __abbr_tips_used also works here:

function launch_editor
    set -g __abbr_tips_used 1
    commandline -i " $EDITOR "
    commandline -f backward-kill-word beginning-of-line yank execute
end
bind \co launch_editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants