WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to change Systemwide PS1 configuration  (Read 133 times)

Offline deodion

  • Jr. Member
  • **
  • Posts: 51
How to change Systemwide PS1 configuration
« on: August 22, 2017, 01:17:56 AM »
How can I change (Systemwide) PS1 parameter or colors?

I try & copy modified /etc/profile to permanent disk in /mnt/sda1/opt/profile
then use /mnt/sda1/opt/bootlocal.sh or bootsync.sh, insert sudo cp /mnt/sda1/opt/profile /etc/profile
and reboot, its not working?

/etc/profile or /mnt/sda1/opt/profile:
Code: (bash) [Select]
if [ "`id -u`" -eq 0 ]; then
        # Light green and blue colored prompt.
        PS1='\e[1;31m\u@\h\e[0m:\e[1;34m\w\e[0m\# '
        #PS1='\u@\h:\w\# '
else
        # Light green and blue colored prompt.
        PS1='\e[1;32m\u@\h\e[0m:\e[1;34m\w\e[0m\$ '
        #PS1='\u@\h:\w\$ '
fi
« Last Edit: August 22, 2017, 01:24:36 AM by deodion »

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1552
Re: How to change Systemwide PS1 configuration
« Reply #1 on: August 22, 2017, 02:08:34 AM »
This procedure would usually go like this:
Modify  /etc/profile  to your needs
 then add  /etc/profile  to  /opt/.filetool.lst
Code: [Select]
echo "etc/profile" >> /opt/.filetool.lst
(Note: the missing leading slash in "etc/profile" is intentional)
 and perform a backup
Code: [Select]
filetool.sh -b

However, I believe  /etc/profile  might be processed before the backup got restored while booting.
Meaning you would have to remaster your initrd. I'm not 100% sure though.
Download a copy and keep it handy: Core book ;)

Offline deodion

  • Jr. Member
  • **
  • Posts: 51
Re: How to change Systemwide PS1 configuration
« Reply #2 on: August 22, 2017, 02:24:26 AM »
What if I add below in bootlocal.sh or bootsync.sh:

sed -i 's|PS1='\u@\h:\w|PS1='\u@@@@@\h:\w|' /home/*/.profile

I'm not used to sed, just copy paste the idea and read abit about it in google,

Offline deodion

  • Jr. Member
  • **
  • Posts: 51
Re: How to change Systemwide PS1 configuration
« Reply #3 on: August 22, 2017, 03:18:40 AM »
I have below in /mnt/sda1/opt/bootlocal.sh:

sudo sed -i 's|\\u@\\h:\\w|\\e[91m\\u@\\h:\\w\\e[39m|' /home/*/.profile

Its working (If using SmartTTY) while login to username tc, Im not sure about other username though,

but from my local VMware Workstation console, the PS1 its not working, still default even I put in bootsync.sh
« Last Edit: August 22, 2017, 03:25:55 AM by deodion »

Offline deodion

  • Jr. Member
  • **
  • Posts: 51
Re: How to change Systemwide PS1 configuration
« Reply #4 on: August 22, 2017, 03:44:53 AM »

Code: (bash) [Select]
sudo sed -i 's|\\u@\\h:\\w|\\e[91m\\u\\e[39m@\\e[93m\\h:\\e[92m\\w\\e[39m|' /home/*/.profile
I use SmarTTY:


sudo su also get the same color, not sure why,

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1552
Re: How to change Systemwide PS1 configuration
« Reply #5 on: August 22, 2017, 04:00:04 AM »
As said above, I believe  /etc/profile  is already processed at the time where the backup gets restored at boot. That means  bootsync.sh  and  bootlocal.sh  would run too late as well.
So, in order to change the PS1 variable systemwide, you would have to edit  /etc/profile  in your initrd.
http://wiki.tinycorelinux.net/wiki:remastering

BTW, bootsync.sh  and  bootlocal.sh  run with root privileges, so no sudo required in these.
Download a copy and keep it handy: Core book ;)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 9560
Re: How to change Systemwide PS1 configuration
« Reply #6 on: August 22, 2017, 08:14:44 AM »
/etc/profile is read every time you log in, so backup should be fine.
The only barriers that can stop you are the ones you create yourself.