8000 Add a function to check if the user is root. by damani42 · Pull Request #7123 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

Add a function to check if the user is root.#7123

Merged
faho merged 1 commit intofish-shell:masterfrom
damani42:7031-fish_is_root_user
Jun 26, 2020
Merged

Add a function to check if the user is root.#7123
faho merged 1 commit intofish-shell:masterfrom
damani42:7031-fish_is_root_user

Conversation

@damani42
Copy link
Contributor
@damani42 damani42 commented Jun 17, 2020

Add a helper function to check if the user is root. This function can be
useful for the prompts for example. Modify the prompts made root checked
to use the function instead. Add also the support of Administrator like
a root user.

Fixes: #7031

@damani42 damani42 force-pushed the 7031-fish_is_root_user branch 2 times, most recently from 559fc8e to 5669271 Compare June 18, 2020 07:58
@faho
Copy link
Member
faho commented Jun 20, 2020

Thank you for your effort!

What I'd really like to see, and what makes the entire thing with the function worthwhile, is to have it used in all of our sample prompts that do this check. E.g. the "debian chroot" prompt has this bit:

switch "$USER"
case root toor
echo -n -s "$USER" @ (prompt_hostname) ' ' (set -q fish_color_cwd_root
and set_color $fish_color_cwd_root
or set_color $fish_color_cwd) (prompt_pwd) \
(set_color normal) '# '
case '*'
echo -n -s "$USER" @ (prompt_hostname) ' ' (set_color $fish_color_cwd) (prompt_pwd) \
(set_color normal) '> '
end

In essence, whenever a prompt checks if the user is "root" anywhere, it should be using that function instead. That includes now using the function whether it used to check for "root" or "toor" or just for "root". The actual coloring and using symbols can stay in the prompt, however.

So: If you're feeling up for it, please check the sample_prompts directory for such uses and replace them with this function.

@faho faho added this to the fish 3.2.0 milestone Jun 20, 2020
Add a helper function to check if the user is root. This function can be
useful for the prompts for example. Modify the prompts made root checked
to use the function instead. Add also the support of Administrator like
a root user.

Fixes: fish-shell#7031
@damani42 damani42 force-pushed the 7031-fish_is_root_user branch from 5669271 to 8badb1b Compare June 23, 2020 21:22
@damani42
Copy link
Contributor Author

I think now I have modified all prompts. Do you see something else, I can modify?

8000

@faho faho merged commit e2f03fa into fish-shell:master Jun 26, 2020
@faho
Copy link
Member
faho commented Jun 26, 2020

Thank you very much, merged!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2020
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.

support Administrator in fish_prompt.fish

2 participants

0