6

I've created an alias in .bashrc file as follows

alias myproject = 'cd ~/Desktop/myproject'

After saving the file when I restart my terminal, typing in myproject takes me to the project directory but when I try to use the alias as a command argument to a new gnome-terminal tab it throws an error,

gnome-terminal --tab -e "myproject"

throws the error

There was an error creating the child process for this terminal
Failed to execute child process "myproject" (No such file or directory)

What is wrong with this ?

Mudassir Ali
  • 7,913
  • 4
  • 32
  • 60

3 Answers3

3

When a bash shell is started, per default bash executes the commands specified in .bashrc. This is how your shell knows your aliases.

Now your idea does not work because gnome-terminal never sees your .bashrc file.

You could try

gnome-terminal --working-directory='<path-to-your-home-directory>/Desktop/myproject/

Josh M.
  • 26,437
  • 24
  • 119
  • 200
Klaus
  • 805
  • 6
  • 7
  • My alias is sourcing the file and getting the same issue. alias gratenv 'source /repo/${USER}/.grat.wd' Failed to execute child process "source setEnvironmentCommands" (No such file or directory) "source /repo/${USER}/.grat.wd" Do you know the root cause of it? I also try to execute this command directly after starting the gnome-terminal but no success. – Kashan Nov 25 '17 at 09:59
1

I was trying to do something similar... possibly not exactly what you want, but:

alias startMyRailsProject='cd ~/Desktop/myproject; gnome-terminal --tab --tab -e "rails s" --tab -e "rails c"; exit'

This: - changes directory to where I want - starts a new gnome terminal (in the right directory from before) - creates a 2nd tab and starts my rails server - creates a 3rd tab and starts my rails console - and then closes the original terminal window which I call it from.
It does what I need it to and saves a bunch of repetive keystrokes :-) Cheers

Josh M.
  • 26,437
  • 24
  • 119
  • 200
user2798692
  • 163
  • 8
1

I succeeded in getting some of it to work, I am missing my aliases, but I can run the program I want in the following way:

gnome-terminal --window --title="testtitle" -- $SHELL -c "<path to script/application>/<script/application> <arguments>;"

An example:

gnome-terminal --window --wait --title="testtitle" -- $SHELL -c "echo test;read -p \"press any key to exit\" -n 1 ;"