Announcement

Collapse
No announcement yet.

Changing the font of username and hostname (but nothing else) in terminal?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Changing the font of username and hostname (but nothing else) in terminal?

    Hi,

    I just switched from Linux Mint KDE, and there is one thing I can't figure out:
    How do you change the font of username and hostname in the Linux Terminal? Both have a green, bold font in Mint - the whole part from line beginning up to either the "$" or "#" symbol (the font is red in the root console).
    It makes it much easier to see where one command ended and the other one began. (All the other fonts except for username and hostname are normal and configurable via Settings - Configure Current Profile - Appearance.)
    Can I set it up like this in Kubuntu?

    Thanks, I'm grateful for any help.

    #2
    Hi & welcome to KFN!

    You can't change the font face/family, but I think you know that.

    To change the font colour or background colour or boldness you need to set the PS1 variable - and this is a bash thing and would apply regardless of what distro you're using.

    Mine, set in ~/.bashrc, for example:
    Code:
    PS1='[\[\033[00;36m\]\u@\h\[\033[00m\]: \[\033[01;37m\]\w\[\033[00m\]] \[\033[01;30m\]\d\[\033[00m\] \t\n\$ '
    - Simple, right? Results in
    Code:
    [[COLOR="#40E0D0"]joe@sourdust[/COLOR]: [B]~[/B]] [COLOR="#A9A9A9"]Tue Mar 13[/COLOR] 21:56:15
    $

    \u is replaced with your username, \h with your hostname, \t with the time, \n is a new-line, etc. See man bash and search for PS1 and PROMPTING for more details.

    The \[\033[00;36m\] constructions change the colour etc. See ansi codes for codes you can use.
    I'd rather be locked out than locked in.

    Comment


      #3
      Hi,

      thank you very much!:-) It worked. Also, thanks for explaining the code - I wish more people would do that, and as efficiently as this.:-)

      Comment

      Working...
      X