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

navi fish plugin with ability to edit commandline #123

Merged
merged 1 commit into from
Oct 14, 2019

Conversation

tfriedel
Copy link
Contributor

@tfriedel tfriedel commented Oct 11, 2019

here's my version of the fish plugin. I adapted it from the fzf plugin which allows to go through the command line history (ctrl-r). the fzf_tmux_height variables don't seem to have an effect.
there's also an issue where if you cancel navi (ctrl-c), you still have some invisible ^C / ctrl-c character left in the commandline. So your next command will not work unless you press ctrl-c again. This should probably be fixed somehow.
I had a problem where the line where I call navi would show prompts when run from the shell, but not in the function. I searched around the fish shell issues and running "stty sane" was suggested as a solution.

@welcome
Copy link

welcome bot commented Oct 11, 2019

Thanks for opening this pull request!

@denisidoro
Copy link
Owner

Related: #37


# Remove last token from commandline.
commandline -t ""
function navi_key_bindings
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you wrapping everything inside this fn?

I tried running source $NAVI_HOME/navi.plugin.fish and it didn't seem to work. Removing this line and the last one makes it work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I adapted the script from the fzf fish script. The bindings are enabled by a line in ~/.config/fish/functions/fish_user_key_bindings.fish

function fish_user_key_bindings
  fzf_key_bindings
  navi_key_bindings
end

Otherwise they are always enabled. Not a big deal though, you can also delete the file if you want it disabled.

function navi-widget -d "Show cheat sheet"
set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%
begin
set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️ (Actually, is this necessary? Why not let the user decide the defaults given his/her .fishrc?)

Copy link
Contributor Author

@tfriedel tfriedel Oct 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessary. I basically left it from the fzf script without thinking deeply if it's necessary. Personally I never used the shortcut to toggle the shorting mode. In the fzf case the idea was probably that you can have different options for different applications of fzf. Now the FZF_TMUX_HEIGHT variable doesn't seem to have an effect anyway. I'm also not sure if navi should support this or not.

@denisidoro
Copy link
Owner

Cool! I'll try to merge this on Monday. Thanks!

@denisidoro denisidoro changed the base branch from master to dev October 14, 2019 16:39
@denisidoro denisidoro merged commit 8b99c86 into denisidoro:dev Oct 14, 2019
@welcome
Copy link

welcome bot commented Oct 14, 2019

Congrats on merging your first pull request!

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

Successfully merging this pull request may close these issues.

None yet

2 participants