0

Currently my PS1 environment variable is displaying as shown below:

enter image description here

The below image is what I would like my PS1 environment variable to display as:

enter image description here

The below is how my PS1 environment variable is set as:

export PS1='$LOGIN@'`hostname`':$PWD> '

Unfortunately I am unsure of how to change my PS1 environment variable to give me what I want and everything I have tried does not work.

Christopher Karsten
  • 387
  • 1
  • 2
  • 12

2 Answers2

1

This should help on a AIX Version 7.1

bold=`tput smso`
norm=`tput rmso`
PS1="${bold}$LOGNAME@`hostname`:${norm}\${PWD}# "
export PS1

enter image description here

MD XF
  • 7,860
  • 7
  • 40
  • 71
Christopher Karsten
  • 387
  • 1
  • 2
  • 12
  • 1
    You might want to edit this post: insert four spaces before program-lines. Or simply: `inv=$(tput smso); norm=$(tput rmso); export PS1="$inv"text"$norm"` – Zsigmond Lőrinczy Nov 08 '16 at 19:38
0

This code should give you the prompt you're looking for:

export PS1="\[\033[38;5;0m\]\[\033[48;5;253m\]\u@\h\[$(tput sgr0)\]\[\033[38;5;15m\]\[\033[48;5;-1m\]:\w\#\[$(tput sgr0)\]"

Add it to your .bashrc or .bash_profile.

You can adjust the background color behind the user@host part by changing the value 253. For example, 240 gives you dark grey and 255 white.

There is a number of bash PS1 generators that you can use to customize your bash prompts. For example, try http://bashrcgenerator.com/

Janek
  • 2,942
  • 1
  • 14
  • 14
  • I added the line you provided and I get this [033[38;5;0m][033[48;5;15m]'chrisk@'dcdev3':/home/chrisk> '[]. I used this 'export PS1="\[\033[38;5;0m\]\[\033[48;5;15m\]\'$LOGIN@'`hostname`':$PWD> '\[$(tput sgr0)\]"' and it does not work – Christopher Karsten Nov 07 '16 at 13:25
  • Maybe try `PS1=$(echo - e "\[\033[38;5;0m\]\[\033[48;5;253m\]\u@\h\[$(tput sgr0)\]\[\033[38;5;15m\]\[\033[48;5;-1m\]:\w\#\[$(tput sgr0)\]")` – Val Berthe Nov 07 '16 at 13:35