LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-08-2005, 09:23 PM   #1
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
problem changing X terminal colors with script


Hi,

I feel kind of silly for asking this, but it's really bugging me. I've written a script that changes the color of my prompt and also changes my title of my X terminals. This script works fine if I type it, but for some reason it doesn't work when used as an executable script. Here's the script...

#!/bin/sh
#script to setup Terminal colors

echo "changing settings"

export PS1="\[\e]2;New Terminal Prefs \t\a\n\[\e[34;1m\]\u@\[\e[31;1m\]\H:\w\n\[\e[0m\]$> "

echo "done"

I get no errors with this script but 'export' doesn't seem to be executed. I don't know of an absolute path for 'export' and coule not find one even using slocate.

Anyone have any ideas how to get this working?

thanks,
phil
 
Old 10-08-2005, 09:29 PM   #2
egag
Senior Member
 
Registered: Jul 2004
Location: Netherlands
Distribution: Slackware
Posts: 2,721

Rep: Reputation: 53
you must put it into a startup-script that the shell reads at startup.
put it in a file named " .profile " in your home dir.

otherwise it's just exported to the shell that runs the script.
and that one closes when the script ends.

egag
 
Old 10-09-2005, 04:03 AM   #3
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
The only way to run that would be using the source command. That will execute the script in your current bash session. Use like: source <file>
 
Old 10-09-2005, 12:33 PM   #4
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Original Poster
Rep: Reputation: 73
thanks for the help Using the 'source' command made the script work correctly. For now I like being able to use this script on individual X terminals. However, if I did want to start an X session so that all started x terminals would have my prefs set how would I do this? I'm currently using Xfce. I thought calling the script in one of the .xinitrc files might do it but I'm not sure. Ideally I could simply activate this manually from the console before starting X, so I would have the choice of whether or not I wanted the prefs on.

Another question I have concerning this topic is how to change the colors for 'ls' I tried exporting new values for LS_OPTIONS but this seemed to have no effect. I get some of what I want if I su - to a user, but I shouldn't need to do this.

Any helpful information on any of this would be greatly appreciated.

thanks a ton for your help,
phil
 
Old 10-09-2005, 12:48 PM   #5
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
I think I know what's the problem. By default terminals in X are not run as login shells so they won't read .bash_profile nor /etc/profile files. They will however, read .bashrc. You can find more about this reading bash man page (INVOCATION section).

To "solve" this and always load the values you want, you've to create a .bashrc file in your home folder with this content:
Code:
if [ -f ~/.profile ]; then
    source ~/.profile
fi
And then create one called .profile also in your home folder with the things you want, like:
Code:
echo "changing settings"
export PS1="\[\e]2;New Terminal Prefs \t\a\n\[\e[34;1m\]\u@\[\e[31;1m\]\H:\w\n\[\e[0m\]$> "
echo "done"
alias ls='ls -Flh --color=auto'
 
Old 10-10-2005, 11:15 PM   #6
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Original Poster
Rep: Reputation: 73
awesome! Thank you very much! The .bashrc file gets loaded at every X terminal startup. To disable this, of course, I simply change the file name. In addition, I noticed that when I su - the accounts .profile file gets loaded. Thank you again!

phil
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing terminal colors Athos Debian 3 09-11-2007 05:54 PM
how to get colors in terminal window? emanresu Linux - Newbie 3 11-15-2005 02:55 PM
Terminal Colors chakkerz Linux - General 2 11-22-2004 09:01 PM
Gnome terminal colors... hjles Slackware 1 11-26-2003 10:29 PM
Terminal Colors dhrivnak Slackware 2 10-26-2003 03:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration