starship / starship

☄🌌️ The minimal, blazing-fast, and infinitely customizable prompt for any shell!
https://starship.rs
ISC License
43.98k stars 1.91k forks source link

Ability to set different character module symbol for normal and root user #2421

Open etircopyh opened 3 years ago

etircopyh commented 3 years ago

Feature Request

Describe the solution you'd like

Would be nice to have this feature to reflect more clear difference of prompt that you're in. For example when user is root then set # symbol as character and when is not then something else. I don't think that there are needed any default values I guess it makes sense for this feature to be disabled by default and override current behavior by user's explicit choice.

AlanGreene commented 3 years ago

This would be great. It's something I have in my current prompt (home grown) and I just spent a while trying to figure out how to get it working in starship.

Edit: Managed to work around this in bash for now… Mileage may vary for other shells so it would still be great to have a starship solution.

[character]
success_symbol = '\$'

from https://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html

\$: if the effective UID is 0, a #, otherwise a $

fadeevab commented 1 year ago

Solution

Step 1: Modify starship.toml config in user mode

vi ~/.config/starship.toml
[character]
success_symbol = "[\\$](green bold)"
error_symbol = "[\\$](red bold)"

Step 2: Switch to the root

sudo -s

Step 3: Modify starship.toml under the root

# /home/root/.config/starship.toml
vi ~/.config/starship.toml
[character]
success_symbol = "[#](green bold)"
error_symbol = "[#](red bold)"
everdrone commented 2 months ago

Bumping this, would be great to have[^1]

[character]
success_symbol = "[%](green)"
error_symbol = "[%](red)"
root_success_symbol = "[#](green)"
root_error_symbol = "[#](red)"

[^1]: on shells different than bash and for other operating systems as well!