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

Default prompt as root user #1022

Closed
tarsiec opened this issue Mar 21, 2020 · 3 comments
Closed

Default prompt as root user #1022

tarsiec opened this issue Mar 21, 2020 · 3 comments
Labels
🐛 bug Something isn't working as expected.

Comments

@tarsiec
Copy link

tarsiec commented Mar 21, 2020

Current Behavior

Right now, whenever I sudo -s in order to login as the root user in my shell, the zsh theme goes back to the default (in my case arch#).
Is this behaviour usual, and either way, what could I do to fix it?
I noticed that there's a Username module in the documentation which should default to appear when with root privileges, but it doesnt't show up.
In order to fix it I, with no hopes for it to work, created a symbolic link in the /root/ directory with my .zshrc, but this doesn't seem to work.
How could I solve this?

Environment

  • Starship version: 0.37.0
  • zsh version: zsh 5.8 (x86_64-pc-linux-gnu)
  • Operating system: Arch Linux
  • Terminal emulator: Kitty

Relevant Shell Configuration

#              __
#  ____  _____/ /_  __________
# /_  / / ___/ __ \/ ___/ ___/
#  / /_(__  ) / / / /  / /__
# /___/____/_/ /_/_/   \___/	t0maslb@github

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.

# scripts
export PATH=$PATH:"$(printf "%s:" ${HOME}/.local/bin/*)"
# encoding
export LANG=en_GB.UTF-8
export LC_ALL=es_ES.UTF-8
# code & langs
export CODE_DIR=$HOME/code
export CODE_RSC=$CODE_DIR/resources
export CODE_PRJ=$CODE_DIR/projects
# rust
export RUSTUP_HOME=$HOME/code/resources/rustup
export CARGO_HOME=$HOME/code/resources/cargo
export PATH=$PATH:$CARGO_HOME/bin
# go
export GOPATH=$CODE_PRJ/go
export PATH=$PATH:$GOPATH/bin
#export GOROOT=/usr/lib/go
export GOBIN=$GOROOT/bin
# zsh: plugins and themes
export STARSHIP_CONFIG=/home/tomas/.config/starship/starship.toml

source $HOME/.local/bin/zsh_plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh


eval "$(starship init zsh)"
eval "$(thefuck --alias)"

alias getvid="youtube-dl --restrict-filenames -f 22"
alias getaudio="youtube-dl --restrict-filenames -x --audio-format mp3"
alias dmi="doas make install"
alias dmci="doas make clean install"
alias drc="sudo make install & pkill dwm"
alias rcst="rm config.h & make & sudo make install"
alias ls="ls --color=auto"
alias l="ls -la"
alias v="vim"

# KEYBINDINGS
bindkey  "^[[H"   beginning-of-line
bindkey  "^[[F"   end-of-line
bindkey "\e[3~" delete-char

/opt/shell-color-scripts/crunchbang-mini

Starship Configuration

add_newline = true

[character]
symbol = ""
error_symbol = ""
vicmd_symbol = ""

[git_status]
staged.value = "++"
staged_count.enabled = true
deleted = "🗑"

[haskell]
symbol = ""

[package]
disabled = false

[time]
disabled = false
format = "[%H:%m]"
@tarsiec tarsiec added the 🐛 bug Something isn't working as expected. label Mar 21, 2020
@chipbuster
Copy link
Contributor

Is starship installed in ~/.local/bin? If so, the line export PATH=$PATH:"$(printf "%s:" ${HOME}/.local/bin/*)" won't work, because $HOME refers to the home of the root user.

Can you run eval "$(starship init zsh)" as root and have the prompt appear? If not, you need to fix that first.

@tarsiec
Copy link
Author

tarsiec commented Mar 24, 2020

Alright, thank you, I figured it out. Turns out I've spent all of my time running Linux without knowing about the existence of the /root direcotry. As soon as I made a .zshrc in that dir, and included eval "$(starship init zsh)" in it, as I'd do in my users home directory, everything ran fine.

@tarsiec tarsiec closed this as completed Mar 24, 2020
@hhlp
Copy link

hhlp commented Jun 5, 2020

Additional to this, the ROOT account default shell is BASH, and if your $USER is under ZSH and your ROOT account is BASH, you should change your ROOT shell from BASH to ZSH for you ROOT one:

usermod --shell /bin/zsh root

Regards.,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working as expected.
Projects
None yet
Development

No branches or pull requests

3 participants