22

I'm on Ubuntu 13.04 and I'd like to configure my terminal, so that every time a new tab/window is open, it executes the following command automatically and right away.

 /bin/bash --login

How could I achieve this? On OSX with iTerm 2 there is an option to run a command on start. I guess here I should achieve this thru some kind of dotfile...

2
  • 1
    Why do you want to do this? When you open a new terminal, this command is already executed.
    – Spack
    May 4, 2013 at 1:27
  • No its not. I need this because of a bug in some development environment I use. The --login flag is crucial. May 4, 2013 at 1:51

2 Answers 2

23

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 of sh 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 daemon sshd. 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.

1
  • in my case, run sudo nano ~/.bashrc and added the command Sep 14, 2022 at 14:00
5

Try:

  • In terminal, Edit > Preferences > Tab Title and command > Run a custom command of my shell.

enter image description here

Or

  • gnome-terminal --tab -e "your command" to open a new tab.

More informations: ManPage Gnome-terminal

1
  • 2
    Actually, just checking the run command as login shell fixed my problem. May 4, 2013 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .