|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How 2 run same command across all open terminals
Hi folks. This has been bothering me for a while. Among the 8 virtual desktops I'm using, I have 18 terminals open right now. I change some of my user configuration (e.g. put a new alias into ~/.bashrc); but in order to use this new added alias, I have to source the config file: Code:
. ~/.bashrc That's all good, but the sourcing stays local to the current terminal. Is there a way to source my .bashrc on ALL open terminals, so that I can use it from any one of them? I know I can echo into any terminal Code:
echo Hello > /dev/pts/15 But is there a way to run a command like this? Something like Code:
$ echo . ~/.basrhc | /dev/pts/15 bash: /dev/pts/15: Permission denied bash: echo: write error: Broken pipe I'm running bash on CentOS box. Thank you! |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
It seems that every shell you run is a login shell. Bash reads and executes the ~/.bashrc file only if it is started as an interactive, but not login shell. When Bash starts as an interactive login shell, it reads and executes the ~/.bash_profile file. What you could do is to source the ~/.bashrc file from the ~/.bash_profile file. Something like this:
# .bash_profile # sourcing .bashrc: . ~/.bashrc this way every interactive shell you start will read and execute the ~/.bashrc file, be it a loging shell or not. |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks for the response.
But that is not my problem. I'd like to source the config file (.bashrc, .bash_profile, .myConfigFile, etc.) across all terminals that are already running. So that I don't have to close them, and restart (and lose history, kill programs tied to them etc.) |
|
#4
|
|||
|
|||
|
To my knowledge you'll have to manually source the rc file in each running instance of the shell. If you want to be clever, and anticipate doing this often enough, you could put the following command into your .bashrc file: Code:
trap ". $HOME/.bashrc" 16 Once that is set in a running instance of bash, you then only need to send a SIGUSR1 (16) to the process and it will resource the .bashrc file. You could write a small script that susses out all of your running login/interactive shells and executes the necessary kill -16 command. You could pick another signal, but this seems just fine for this case. Hope this helps some. Last edited by agama; 05-09-2011 at 10:46 PM.. Reason: typo |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks agama,
That's a slick solution there with SIGUSR1, that can be certainly put to use. I also have had the feeling it cannot be done straightforward. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to open multiple virtual terminals to a single LPAR | wingcross | AIX | 1 | 02-22-2011 10:14 AM |
| The "PS" command was displaying*terminals named as "SYSCON" | kiranjose85 | UNIX for Advanced & Expert Users | 1 | 11-28-2008 06:53 AM |
| one command for all unix terminals | rgmekala | UNIX for Advanced & Expert Users | 5 | 05-09-2006 10:25 AM |
| what is the command to connect to remote terminals | sendtorohitgupt | UNIX for Dummies Questions & Answers | 1 | 05-10-2005 02:08 PM |
| view all others terminals | vkandati | UNIX for Dummies Questions & Answers | 2 | 03-08-2005 06:27 PM |
|
|