How can I change my root prompt?

  • This is my desired prompt (I would like colors too, but, as long as sh should be the shell for root, I have read it is hard to achieve):

    PS1="`whoami`@`hostname | sed 's/\..*//'`~ $PWD>"

    How can I change the default prompt for root user to this one?
    I logint into my pfSense machine via SSH remote connections. I don't know if the change should be the same for physical access.

  • Galactic Empire

    You could try editing ~/.tcsh

    [2.4.3-RELEASE][]/root: ls -alg .tcshrc 
    -rw-r--r--  1 root  wheel  2418 Jun 25 19:55 .tcshrc
    [2.4.3-RELEASE][]/root: grep prompt .tcshrc 
    set prompt="[%B`cat /etc/version`%b][%B%n%b%{\033[0;1;31m%}@%{\033[0;0;0m%}%B%M%b]%/%{\033[0;1;31m%}:%{\033[0;0;0m%} "

  • @nogbadthebad

    Not working:

    [\033[00;32m]\u@Balanceador[\033[00m]:[\033[01;34m]/root[\033[00m]$ whoami
    [\033[00;32m]\u@Balanceador[\033[00m]:[\033[01;34m]/root[\033[00m]$ echo $SHELL
    [\033[00;32m]\u@Balanceador[\033[00m]:[\033[01;34m]/root[\033[00m]$ pwd
    [\033[00;32m]\u@Balanceador[\033[00m]:[\033[01;34m]/root[\033[00m]$ grep PS1 .tcshrc
    export PS1="`whoami`@`hostname | sed 's/\..*//'`~ $PWD>"
    [\033[00;32m]\u@Balanceador[\033[00m]:[\033[01;34m]/root[\033[00m]$ grep prompt .tcshrc
    set prompt="`whoami`@`hostname | sed 's/\..*//'`~ $PWD>"

    Of course, I tried reloging in.

  • Galactic Empire

    tcsh != sh

    You'll need to look at the tcsh man pages.

  • @nogbadthebad
    Obviously, tcsh is not sh . I never said I was using tcsh.

    Neither does the .shrc file seems to solve the problem:

    $ grep PS1 .shrc
    PS1="`whoami`@`hostname | sed 's/\..*//'` ~$PWD > "
    $ grep VISUAL .shrc
    $ echo $PS1
    $ echo $VISUAL

    It seems the .shrc file is ignored too.

  • Galactic Empire

    @nogbadthebad said in How can I change my root prompt?:


    The default shell is tcsh that's why i stated tcsh != sh, I didn't spot the bit where you mentioned echo $SHELL

Log in to reply