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][admin@pfsense.xxxx.net]/root: ls -alg .tcshrc 
    -rw-r--r--  1 root  wheel  2418 Jun 25 19:55 .tcshrc
    [2.4.3-RELEASE][admin@pfsense.xxxx.net]/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%} "
    [2.4.3-RELEASE][admin@pfsense.xxxx.net]/root: 
    


  • @nogbadthebad

    Not working:

    [\033[00;32m]\u@Balanceador[\033[00m]:[\033[01;34m]/root[\033[00m]$ whoami
    root
    [\033[00;32m]\u@Balanceador[\033[00m]:[\033[01;34m]/root[\033[00m]$ echo $SHELL
    /bin/sh
    [\033[00;32m]\u@Balanceador[\033[00m]:[\033[01;34m]/root[\033[00m]$ pwd
    /root
    [\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
    VISUAL=nano
    
    $ echo $PS1
    [\033[00;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]$
    
    $ echo $VISUAL
    [nothing]
    

    It seems the .shrc file is ignored too.


  • Galactic Empire

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

    0;1;31m

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


 

© Copyright 2002 - 2018 Rubicon Communications, LLC | Privacy Policy