Change profile of gnome-terminal from script?

Asked by esbenjannik

Hi
  I would like to know if its possible to change profile of the running gnome-terminal window from "within" bash. I would like to change the profile when I log into our server, change some environment setting, is root etc. I can start a new terminal window with the --window-with-profile= setting, but is there a way to do it for the already open window from within a script. Now I change profile with the menus when I log in and I find that annoying and riskprone. There are commands which are OK to use on my workstation, but not on the server. So if theres a way to get the profile to respond to the current shell (evt. via a script), I would be thrilled to know.

Esben

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gnome-terminal Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Ralph Janke (txwikinger) said :
#1

Bash uses configuration files with in the userspace, .bashrc and .bash_profile which are located within your home directory. I am not 100% sure what you want to do, but you can change settings there like the environment variables etc.

You can also run any script from your window that does this. However, if you set environment variables you should "source" the script rather then just execute it (In order not to create a child process which doesn't change the variables in your current shell). You do it by having a leading "." (i.e. ". <scriptname>". Obviously, your script must be executable according to the file permissions. You can also use "source" instead of "." in bash IIRC.

You can have different settings on different computers if you have individual home directories on each of them (server/workstation), Or you can check for hostname, ip-address or some other characteristic in your script in order to enable something or set a particular value.

If you have a more concrete question, please ask, otherwise I hope this helps you to get in the right direction.

Revision history for this message
esbenjannik (esbenjannik) said :
#2

Hi
    Thanks for your answer, But I think you misunderstood my question. I want to change the profile of the gnome-terminal (text and background color etc.), from a loginscript in some automatic way. Is the current profile of the gnome-terminal defined in a env. setting? Is it possible to change the profile (gnome-terminal text and bg colors) from the command line? and if so how? If I just knew how to do it from the shell in the current gnome-terminal window (and not having to use the mouse and menus), I could take care of the rest by some script in .bashrc that checks the hostname or IP.

Best Regards
Esben

----- Original Message ----
From: txwikinger <email address hidden>
To: <email address hidden>
Sent: Tuesday, April 3, 2007 2:27:15 PM
Subject: Re: [Question #4582]: Change profile of gnome-terminal from script?

Your question #4582 on gnome-terminal in ubuntu changed:
https://answers.launchpad.net/ubuntu/+source/gnome-terminal/+ticket/4582

    Status: Open => Answered

txwikinger proposed the following answer:
Bash uses configuration files with in the userspace, .bashrc and
.bash_profile which are located within your home directory. I am not
100% sure what you want to do, but you can change settings there like
the environment variables etc.

You can also run any script from your window that does this. However, if
you set environment variables you should "source" the script rather then
just execute it (In order not to create a child process which doesn't
change the variables in your current shell). You do it by having a
leading "." (i.e. ". <scriptname>". Obviously, your script must be
executable according to the file permissions. You can also use "source"
instead of "." in bash IIRC.

You can have different settings on different computers if you have
individual home directories on each of them (server/workstation), Or you
can check for hostname, ip-address or some other characteristic in your
script in order to enable something or set a particular value.

If you have a more concrete question, please ask, otherwise I hope this
helps you to get in the right direction.

_______________________________________________________________________
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/ubuntu/+source/gnome-terminal/+ticket/4582/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/ubuntu/+source/gnome-terminal/+ticket/4582

____________________________________________________________________________________
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/

Revision history for this message
Ralph Janke (txwikinger) said :
#3

I am not sure about gnome-terminal. However, if you use Konsole, you can send a message via dcop to it which which you could change the titel of the session or the profile settings (i.e. background color)

I hope this helps

Revision history for this message
NikhilNK (nikhil-katkoria) said :
#4

I was struggling with some requirement, finally using Konsole and .bash_profile was able to resolve it.

Konsole refers .bash_profile (or respective startup script for the given shell) whenever a new window or new tab is opened.

Revision history for this message
rduke15 (rduke15) said :
#5

This question is listed an answered, but it is not. Like the original poster, I also use gnome-terminal for ssh logins into different servers, and would like to have a script which, before the ssh login, would change the terminal colors, and set the character encoding right.

Can an open Terminal window accept commands from a script or alias to load a specific profile and set a specific character encoding?

Can you help with this problem?

Provide an answer of your own, or ask esbenjannik for more information if necessary.

To post a message you must log in.