Tiny Core Linux
General TC => General TC Talk => Topic started by: deodion on August 22, 2017, 05: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:
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
-
This procedure would usually go like this:
Modify /etc/profile to your needs
then add /etc/profile to /opt/.filetool.lst
echo "etc/profile" >> /opt/.filetool.lst
(Note: the missing leading slash in "etc/profile" is intentional)
and perform a backup
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.
-
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,
-
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
-
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:
(http://i68.tinypic.com/2e5494y.png)
sudo su also get the same color, not sure why,
-
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 (http://wiki.tinycorelinux.net/wiki:remastering)
BTW, bootsync.sh and bootlocal.sh run with root privileges, so no sudo required in these.
-
/etc/profile is read every time you log in, so backup should be fine.