petobens / trueline

Fast and extensible bash powerline prompt with true color and fancy icon support
MIT License
385 stars 36 forks source link

SSH display for root on remote machine #41

Open sbushmanov opened 3 years ago

sbushmanov commented 3 years ago

When on a remote SSHed session as a user SSH status is displayed properly.

However, when switched to root SSH status disappears.

image

Would it make sense to keep on displaying SSH status when root as well?

petobens commented 3 years ago

Good catch. I'll try to have a look over the weekend.

onelittlehope commented 1 year ago

Change this:

_trueline_has_ssh() {
    if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then
        echo 'has_ssh'
    fi
}

to:

_trueline_has_ssh() {
    if [[ -n "$SSH_CLIENT" ]] || [[ -n "$SSH_TTY" ]]; then
        echo 'has_ssh'
    else
        # Source: https://serverfault.com/a/773890
        if pstree -p | egrep --quiet --extended-regexp ".*sshd.*\($$\)"; then
          echo 'has_ssh'
        fi
    fi
}