Results 1 to 7 of 7

Thread: Creating a Custom Prompt in openSUSE 15.3 Leap

  1. #1

    Question Creating a Custom Prompt in openSUSE 15.3 Leap

    I am hoping someone can help a CentOS refusenik. I am the Official Test Guinea Pig and in search of an OS for a pair of workstations. openSUSE is on my short list of candidates because it runs KDE out of the box, so I am putting it through its paces, tricking it out, etc. to see IF it will work, and what problems we will encounter.

    One problem -- among others -- I have so far encountered is the ability to create a custom prompt.


    I'm coming over from CentOS (having used Mandrake, Red Hat, Fedora, and RHEL). I am trying​ to create a custom prompt in openSUSE which is EASY in CentOS: => edit /etc/bashrc => find the line that starts PS1 and edit => SAVE. In openSUSE 15.3 Leap I GoTo /etc and find bash.bashrc told NOT to EDIT => create a file called /etc/bash.bashrc.local then go looking for the bash line that starts => PS1 that I wish to edit to now read:



    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\[\033[1;32m\][\[\033[1;33m\]\u\[\033[1;36m\]@\h\[\033[1;31m\]\w\[\033[1;32m\]]\[\033[1;35m\]/>\[\033[1;37m\]"



    to create a colorized prompt that looks like this:



    [root@leopard/home/cat]/>



    or a colorized ~ home prompt that looks like this:



    [cat@leopard~]/>



    No such luck. I then thought I would get sneaky by installing zsh which I am familiar with in CentOS and copy and install my custom theme -- cat-theme -- that I created but came >-< this close to toasting the system for the second time, but I was able to recover it just in time. Now I am back at square 1: modifying /etc/bash.bashrc (local)... with no idea how to modify it... or even WHERE to modify it. In theory I should only need to copy and paste my PS1 statement SOMEWHERE and SAVE the file, but I'll be ********** if I know where in /etc/bash.bashrc (.local wherever or however that is created). This is driving me NUTS!!!



    PLEASE HELP!!!I am sure those old timers that have been hacking openSUSE or SuSE have probably hacked their prompts at one time or the other. Any help you can provide would be greatly appreciated.

    Sincerely,

    D'Cat
    Last edited by desertcat; 16-Jul-2021 at 23:52. Reason: fonts too small

  2. #2
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,169

    Default Re: Creating a Custom Prompt in openSUSE 15.3 Leap

    In general, you should not create a global bashrc change but rather do so for the user in question.

    So, edit ~/.bashrc and add
    Code:
    PS1="\[\033[1;32m\][\[\033[1;33m\]\u\[\033[1;36m\]@\h\[\033[1;31m\]\w\[\033[1;32m\]]\[\033[1;35m\]/>\[\033[1;37m\] "
    At the end of it. Once you open a new shell, the change should take effect.

    FYI, if you're really into customizing your shell - take a peek at OhMyBash at
    Code:
    https://github.com/ohmybash/oh-my-bash
    and OhMyZSH at
    Code:
    https://ohmyz.sh/
    It's neverending fun of customizing your shell :-)
    .: miuku @ #opensuse @ irc.libera.chat

  3. #3
    Join Date
    Sep 2012
    Posts
    6,773

    Default Re: Creating a Custom Prompt in openSUSE 15.3 Leap

    Quote Originally Posted by desertcat View Post
    Code:
    [ "$PS1" = "\\s-\\v\\\$ " ] &&  PS1="\[\033[1;32m\][\[\033[1;33m\]\u\[\033[1;36m\]@\h\[\033[1;31m\]\w\[\033[1;32m\]]\[\033[1;35m\]/>\[\033[1;37m\]"
    Did you check that PS1 actually has default value where and when you test it?

    P.S. your message is near to unreadable due to all those rainbow colors and font changes.

  4. #4
    Join Date
    Jun 2008
    Location
    Delta Quadrant
    Posts
    1,451

    Default Re: Creating a Custom Prompt in openSUSE 15.3 Leap

    I just use Konsole and use the Edit Profile inside of that app.
    If you want something even more fun try Yakuake.

  5. #5
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,358

    Default Re: Creating a Custom Prompt in openSUSE 15.3 Leap

    @desertcat:

    Quote Originally Posted by Miuku View Post
    In general, you should not create a global bashrc change
    If you need to make the change globally – which is what I do to force a short path on the prompt – drop the ‘/etc/bash.bashrc’ changes into ‘/etc/bash.bashrc.local’ …

  6. #6
    Join Date
    May 2012
    Location
    Finland
    Posts
    2,169

    Default Re: Creating a Custom Prompt in openSUSE 15.3 Leap

    Quote Originally Posted by dcurtisfra View Post
    If you need to make the change globally – which is what I do to force a short path on the prompt – drop the ‘/etc/bash.bashrc’ changes into ‘/etc/bash.bashrc.local’ …
    I still stand behind my "I wouldn't do it" -thing because you can end up breaking your ability to login with any user or at least cause grey hair :-)
    .: miuku @ #opensuse @ irc.libera.chat

  7. #7
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,358

    Default Re: Creating a Custom Prompt in openSUSE 15.3 Leap

    Quote Originally Posted by Miuku View Post
    because you can end up breaking your ability to login with any user
    Yes, the code in ‘/etc/bash.bashrc’ is not for the faint-hearted but, the rule has to be –
    1. From within a user's session, with root privileges edit ‘/etc/bash.bashrc.local’ and then write the changes.
    2. From another terminal session, “su --login «another user name»” …
    3. Continue editing ‘/etc/bash.bashrc.local’ until the “su --login «another user name»” succeeds …
    4. Alternatively, use a remote SSH session to check that the system login succeeds – before you logout from the session being used to edit ‘/etc/bash.bashrc.local’ …

    Yes, editing the login scripts can lock you out of the system but, sometimes it pays to “bite the bullet” …

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •