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

A cli prompt selector #7958

Merged
merged 1 commit into from
May 1, 2021
Merged

A cli prompt selector #7958

merged 1 commit into from
May 1, 2021

Conversation

faho
Copy link
Member

@faho faho commented Apr 27, 2021

It's a bit weird to have to fire up a browser to get fish_config to
choose a prompt.

So this adds prompt:

  • prompt list shows all the available prompt names
  • prompt show demos the available sample prompts
  • prompt choose sources a prompt
  • prompt save makes the choice permanent

Part of #3625.

This means that you can e.g. pick the "informative" prompt by adding prompt choose informative to config.fish, and it will just always source the one from the currently installed fish (so it will update when we update the sample). This is on purpose and has basically no overhead, so it's entirely acceptable - we might even want to recommend it in the docs.

TODOs:

  • This does not currently correctly show the right prompt, which is awkward
    to do because we'd have to move it to the right (and this involves width-without-color, see string pad doesn't work with escapes #7784).
  • How about the name? prompt, or maybe a more general "config tool"? A special mode for fish_config, so if you do fish_config prompt it'll run in the terminal, fish_config will keep opening the browser?
  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

@faho faho added this to the fish 3.3.0 milestone Apr 27, 2021
@faho faho added the RFC label Apr 27, 2021
@zanchey
Copy link
Member

zanchey commented Apr 27, 2021

This is rad.

image

Name: There's only one package in Debian that has a /usr/bin/prompt command, and it's libmodglue1 which is installed on a tiny fraction of reporting Debian installs, so I don't think prompt is bad as such... but I wonder if fish_choose_prompt or something would be better. Alternatively, I do like the idea of fish_config being able to do both terminal and Web configuration, with autodetection (eg for SSH) and an appropriate override flag.

UI: I think a bare prompt should be the same as prompt list. I think prompt choose should probably imply prompt save.

@faho
Copy link
Member Author

faho commented Apr 27, 2021

I think prompt choose should probably imply prompt save.

The idea here is that you can use prompt choose to test-drive a prompt - you can do prompt choose scales, then cd around a bit, run a few commands, see what it does.

Or, like I added in above, you can just add prompt choose scales in config.fish and it will track the updates to the sample (this would make #7918 nicer because it would allow us to remove the now-useless function!).

We could add a prompt choose --save shorthand (like funced --save), but I do believe not saving by default is correct, because test-driving is a very normal thing to do.

return 1
end

set -l prompt_dir $__fish_data_dir/sample_prompts $__fish_data_dir/tools/web_config/sample_prompts
Copy link
Member Author

Choose a reason for hiding this comment

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

(note: This was added in preparation of moving the sample_prompts directory out of web_config - because it no longer is web-exclusive)

@faho
Copy link
Member Author

faho commented Apr 27, 2021

I think a bare prompt should be the same as prompt list.

Done

@faho
Copy link
Member Author

faho commented Apr 27, 2021

Current output:
Screenshot_20210427_185524

@faho
Copy link
Member Author

faho commented Apr 28, 2021

Alright, moved it over to fish_config. It's now fish_config prompt <subcommand>.

The web-ui can be accessed via fish_config or fish_config browse. Selecting the initial tab (which is a feature I doubt many people use or know about) can now only be done with fish_config browse.

@faho
Copy link
Member Author

faho commented May 1, 2021

Alright, selecting the initial tab is broken anyway (even without this). I'm just gonna remove it. Fixed it, turns out the URL changed at some point.

It's a bit weird to *have* to fire up a browser to get fish_config to
choose a prompt.

So this adds a `prompt` subcommand to `fish_config`:

- `fish_config prompt list` shows all the available prompt names
- `fish_config prompt show` demos the available sample prompts
- `fish_config prompt choose` sources a prompt
- `fish_config prompt save` makes the choice permanent

A bare `fish_config` or `fish_config browse` opens the web UI.

Part of fish-shell#3625.

TODO: This shows the right prompt on a new line. Showing it in-line is awkward
to do because we'd have to move it to the right.
@faho faho merged commit 2b74aff into fish-shell:master May 1, 2021
@faho
Copy link
Member Author

faho commented May 1, 2021

Alright, merged.

@faho faho deleted the prompt branch July 29, 2021 15:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2022
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

2 participants