On 9/1/19, Computer Planet <deb...@cpnetserver.net> wrote: > Hi guys! > I'm trying, trying and trying but... > > How I Can put in hte end of a bash script this command: > PS1="\[\e]0;\u@\h: > \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w > #\[\033[91m\] " > so that after finishing the script the prompt will write in red...? > > If I try in prompt # PS1="\[\e]0;\u@\h: > \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w > #\[\033[91m\] " > command no problem, write in red until exit or reboot.
You have to source the script instead of running it. I'm not entirely clear about a new shell gets it's own env that disappears when the shell exits thing, but try this: $ cat setps1 ##!/bin/bash # can i change ps1 from a script? echo "FOO = ${FOO}" export FOO=BAR echo "FOO now = ${FOO}" export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w #\[\033[91m\] ' $ export FOO=FOO $ ./setps1 FOO = FOO FOO now = BAR $ echo $FOO FOO See? FOO is back to it's pre ./setps1 value Now try $ source setps1 Lee