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

Fast and functional replacement for __fish_describe_command for Macos #7365

Closed
wants to merge 5 commits into from

Conversation

folke
Copy link
Contributor

@folke folke commented Oct 1, 2020

Description

Macos no longer comes with a whatis database, which makes __fish_describe_command and __fish_complete_man command very slow, since apropos rebuilds the database every time it is invoked.

Trying to update the whatis database as root also doesn't work, because it's on a read only file system.

The solution I implemented, simply creates a whatis database in the user directory at ~/.cache/fish/whatis

The whatis cache is being updated at most once a day.

The result of these changes on macos are:

  • instant command completion
  • instant man completion
  • correctly working command descriptions

Fixes issues #6270, #6611, #6615 and possibly others.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

@folke
Copy link
Contributor Author

folke commented Oct 1, 2020

If needed in other parts of the codebase, the whatis command can be replaced with a grep like so:

/usr/bin/grep -i "\b$argv\b" ~/.whatis.db

@faho
Copy link
Member

faho commented Oct 1, 2020

If needed in other parts of the codebase, the whatis command can be replaced with a grep like so:

Are you sure? Is the format actually line-based like that, or is that just a coincidence? What if $argv occurs in other parts of the line?

I'd rather pass the db to whatis, if at all possible

share/functions/__fish_describe_command.fish Outdated Show resolved Hide resolved
share/functions/__fish_describe_command.fish Outdated Show resolved Hide resolved
share/functions/__fish_describe_command.fish Outdated Show resolved Hide resolved
share/functions/__fish_describe_command.fish Outdated Show resolved Hide resolved
@folke
Copy link
Contributor Author

folke commented Oct 1, 2020

If needed in other parts of the codebase, the whatis command can be replaced with a grep like so:

Are you sure? Is the format actually line-based like that, or is that just a coincidence? What if $argv occurs in other parts of the line?

I'd rather pass the db to whatis, if at all possible

I actually found a way where we can use the system apropos script directly (and possibly whatis, using

@folke folke closed this Oct 1, 2020
@folke folke reopened this Oct 1, 2020
@faho faho added this to the fish 3.2.0 milestone Oct 1, 2020
@folke folke requested review from faho and krobelus October 1, 2020 16:56
@folke folke requested a review from faho October 1, 2020 17:06
@folke folke requested a review from faho October 1, 2020 18:23
Copy link
Member

@faho faho left a comment

Choose a reason for hiding this comment

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

Looks alright to me, if someone on macOS could confirm that it works that would be lovely.

@ridiculousfish
Copy link
Member

This is great! The only issue I see is that the makewhatis call is visibly slow. I think I will make it run in the background instead, if the database already exists.

@ridiculousfish
Copy link
Member

Merged as a6a0d43 with my changes to run makewhatis in the bg as a6686ca. Thank you, awesome contribution!!

@folke
Copy link
Contributor Author

folke commented Oct 4, 2020

@ridiculousfish that makes a lot of sense. Thanks!

@cap10morgan

This comment has been minimized.

@faho

This comment has been minimized.

@dorianmariefr

This comment has been minimized.

stefanvanburen added a commit to stefanvanburen/dotfiles that referenced this pull request Mar 26, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants