Not registered yet?
Register now! It is easy and done in 1 minute and gives you access to special discounts and much more!
After each login, there's certain commands that I run on specific tabs of gnome-terminal. This is a tedious process, so can this be done automatically?
I am seeing here a lot of stuffs. Probably you do not need anything of this.
These are the steps that I did in my Oracle 5.9 Linux:
It worked for me. Of course, in my case, I just want to run .profile to setup my terminal environment.
You can start multiple commands on the same gnome-terminal command line by specifying the --tab-with-profile option multiple times, followed each time by a single -e specifying what command to run in that tab. You can also use --window-with-profile to have multiple windows. For example, the following command starts two windows with two tabs each; the first window runs bash in each tab, setting the environment variable TAB to 1 or 2; the second window runs htop in one tab and iotop in the other tab. The explicit sh invocation, with correct quoting, is necessary for some reason.
gnome-terminal --tab-with-profile="Default" -e 'sh -c '\''export TAB=1; exec bash'\' \
--tab-with-profile="Default" -e 'sh -c '\''export TAB=2; exec bash'\' \
--window-with-profile="Default" -e 'htop' \
--tab-with-profile="Default" -e 'iotop'
If you want a command to run when you log in, put it in a shell script (for example ~/bin/my_gnome_login_commands, and register it in “System / Preferences / Startup Applications” in the Gnome menu. Alternatively, create a file ~/.config/autostart/my_commands.desktop containing
(You must use the full path to your home directory on the Exec= line, you can't use ~.)
(This answer has been tested with Gnome 2.30 on Ubuntu 10.04. As Gnome sometimes breaks compatibility, it may or may not apply to other versions.)
Yes, there is a way. You need to tell gnome-terminal to launch tabs with certain profiles; these profiles must be setup to start a shell with the commands you want.
First, you need to make a script (or a launcher icon) that will start gnome-terminal --tab-with-profile=Dev. "Dev" is the name of a profile you will create, so replace that with whatever you want it to be. Also, you can specify as many --tab-with-profiles as you want: it will open a tab for each.
Now, you need the profile you just referenced. This is created by opening gnome-terminal, and finding Edit->Profiles... in the menu. Make a new profile and give it the name you specified in the previous step. Next, you need to set its preferences. Highlight the newly created profile and click the Edit button. When the Profile Preferences dialog is up, activate the "Title and Command" tab, check "Run a custom command..." and in the associated textbox, put sh -c "ENV=$HOME/.dev_profile sh". Of course, you can set ENV to any path you want, as long as you are consistent in the next step. This starts sh, and sh will execute whatever commands are in $HOME/.dev_profile
sh -c "ENV=$HOME/.dev_profile sh"
Next, you need to create that shell profile file. So edit $HOME/.dev_profile (or whatever file you specified in the previous step). Place whatever commands you want in there; they will be executed when the shell is started. Treat this like you would a .bashrc - this will replace it. Depending on how your .bashrc is setup, you may want to source $HOME/.bashrc in the profile to copy all the functionality over from your normal sh profile.
By the way, I would highly recommend tmux or GNU Screen instead. They are terminal multiplexers that are a bit easier to setup for this kind of thing, and you can use them over an ssh connection. The only disadvantage is that they don't have tabs for you to click on, but you can get a menu list of windows or sessions that you can navigate up and down through and to switch to one. They also have other fancy options like split-screen, activity/inactivity monitors, and the ability to keep the session open without a terminal attached.
Screen has advantages, but it also has downsides. One is that scrolling back to past output is harder than with most X terminal emulators. Another is that you can't easily have two windows from the same screen session displayed at the same time (this is not a problem if you use separate screen sessions, but then you need to switch between them, which separate terminal emulator tabs or windows makes easier).
@Giles: Or Screen is easier to scroll: it depends on the way you like to work. I'm not sure what you mean about the two windows - I do it all the time: ^a S ^a <tab> ^a c
yes that is much simpler than double clicking the tab bar
@Falmarri: actually it is. I touch the mouse infrequently enough that the optical sensor turns itself off so I have to wave it around for about 1.5 seconds before I can click anything. (Not to mention it means moving my hand off the keyboard and having to find the home location on the keyboard again.)
What is a mouse? I've never heard of one. Where can I get one?