Execute a command every time Terminal is open
Solution 1:
Add the command to your ~/.bashrc
. Technically, you should be able to add to ~/.profile
as well, from man bash
, INVOCATION
documentation:
If bash is invoked with the name
sh
, it tries to mimic the startup behavior of historical versions ofsh
as closely as possible, while conforming to the POSIX standard as well. When invoked as an interactive login shell, or a non-interactive shell with the--login
option, it first attempts to read and execute commands from/etc/profile
and~/.profile
, in that order.
Also:
Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the remote shell daemon, usually
rshd
, or the secure shell daemonsshd
. If bash determines it is being run in this fashion, it reads and executes commands from~/.bashrc
and~/.bashrc
, if these files exist and are readable.
So, this means that if you're logged in locally you should be OK using ~/.profile
; but, if you ssh to systems then you'll want to use ~/.bashrc
. ~/.bashrc
also applies when logged in locally; so, it has just become convention to use that.
Solution 2:
Try:
- In terminal, Edit > Preferences > Tab Title and command > Run a custom command of my shell.
Or
-
gnome-terminal --tab -e "your command"
to open a new tab.
More informations: ManPage Gnome-terminal