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

sample fish prompts call hostname too often #3480

Closed
krader1961 opened this issue Oct 23, 2016 · 2 comments · Fixed by #3482
Closed

sample fish prompts call hostname too often #3480

krader1961 opened this issue Oct 23, 2016 · 2 comments · Fixed by #3482
Assignees
Milestone

Comments

@krader1961
Copy link
Contributor

Some of the sample fish prompts (in share/tools/web_config) run hostname every time the prompt is displayed. That command can be slow if, for example, there is a problem with DNS. All of the prompts should use this pattern:

# Just calculate this once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
        set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
end

That's from share/functions/fish_prompt.fish. Obviously we can now do it slightly faster using the string builtin.

This issue was triggered by issue #3479.

@krader1961 krader1961 added this to the fish-future milestone Oct 23, 2016
@krader1961 krader1961 self-assigned this Oct 23, 2016
@floam
Copy link
Member

floam commented Oct 23, 2016

Is there anything we can do to have the cached name time out or trigger hostname to re-run if it changes?

@faho
Copy link
Member

faho commented Oct 23, 2016

Is there anything we can do to have the cached name time out or trigger hostname to re-run if it changes?

Not really. Well, we would theoretically be able to set up some kind of notification, but that's quite a bit of code for very little gain.

This is one of the cases where you should just restart your shell if it bugs you that much.

Some of the sample fish prompts (in share/tools/web_config) run hostname every time the prompt is displayed.

This is also an opportunity for cleanup. Even the prompts that do the right thing all have the code duplicated.

We should introduce a function, fish_prompt_hostname that does this caching and just echoes the hostname.

@faho faho modified the milestones: fish 2.4.0, fish-future Nov 14, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants