This question already has an answer here:

I'm trying to use the gnome-terminal profiles to cd to a given directory and register some aliases just after the terminal opens.

I have created a script:


alias up='docker-compose up -d'
alias down='docker-compose stop'

Then a new gnome-terminal Project 1 profile running the following as "custom command"

bash -c "cd ~/Document/project1;. ./ops-setup.sh"

I can see my script launched when I open the terminal with this profile, the terminal remains opened but it does not leave the prompt.

The child process exited normally with status 0.

I tried to add a bash run after it so the prompt remains

bash -c "cd ~/Document/project1;. ./ops-setup.sh";bash

but no alias registered (I guess that's because it is a new process)

I also tried --init-file

bash --init-file <(echo "cd ~/Document/project1;. ./ops-setup.sh")

but bash complains

bash: cd ~/Document/project1;. ./ops-setup.sh): No such file or directory

How can I keep my aliases registered for this Project 1 profile ?

There are multiple ways to keep the terminal opened after running scripts and I that's not my issue. I'm really talking about keeping aliases registered

marked as duplicate by dessert, karel, Eric Carvalho, waltinator, David Foerster Mar 11 '18 at 19:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please explain me how this is a duplicate. I explicitly tell that I'm not trying to run a script without closing the terminal. My issue was not there. – Pierre de LESPINAY Mar 12 '18 at 10:13

Following @dessert suggestion using a script that includes bashrc as init-file, here is was I did:


PROJECT_PATH=`dirname ${BASH_SOURCE[0]}`   

if [ -f ~/.bashrc ]; then
    source ~/.bashrc

source $PROJECT_PATH/ops-setup.sh

And defined this custom command in the gnome-terminal profile:

bash --init-file ~/Documents/project1/bash-wrapper.sh
  • Wow, now I'm getting delete votes here ? For real ? Any explanation ? Is it a really bad answer ? – Pierre de LESPINAY Mar 12 '18 at 10:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.