3

I'm asking this question because I tried a lot of solutions I found and they all didn't work:

  • gnome-terminal --save-config=... results in an error that this option is no more possible
  • gnome-terminal --tab -- 'vim ~/Files/file.txt' for creating a shell script results in an error, my system is in German but it seems to be like There was an error creating the child process for this terminal Failed to execute child process "vim ~/Files/file.txt" (No such file or directory) and does nothing but using just vim without a file to open works
  • using a session manager just opens the Terminal automatically but without any tabs
  • and gnome-terminal --tab -- 'cd ~/Files/' doesn't work as well (error like the one above)

The version is # GNOME Terminal 3.28.2 using VTE 0.52.2 +GNUTLS -PCRE2. Maybe there are mistakes in my ways of solving it or you know another (a better) alternative?

Thank you for helping me!

  • Does Opening multiple tabs with gnome-terminal help? – dessert Jan 20 at 9:02
  • 1
    Thank you for the link. I hope I understand it right but setting the variable in .bashrc and typing gnome-terminal --tab -- 'bash -c "export BASH_POST_RC=\"vim todo.txt\"; exec bash"' doesn't work, too. – TravelTrader Jan 20 at 9:24
  • No, I think you should add the line eval "$BASH_POST_RC" (literally!) to the end of your ~/.bashrc and run e.g.: gnome-terminal --tab -e 'bash -c "export BASH_POST_RC=\"vim todo.txt\"; exec bash"' --working-directory="$HOME/Files" --tab -e 'exec bash' I’m not sure about the last ` -e 'exec bash'`, try with and without it. – dessert Jan 20 at 11:49
  • With the last phrase it opens 2 tabs, one with the working-directory and one with the error I had before. And without the last phrase only one tab with the directory. – TravelTrader Jan 20 at 12:14
1

The closest I can find that would do this involves creating multiple scripts. gnome-terminal has changed over the years and the -x and --command options have been heavily deprecated. Your best bet is to create profiles for each of the tabs you want to run and use:

gnome-terminal --tab-with-profile=Something1 --tab-with-profile=Something2

If you're using stuff like ~ or * inside your commands it's likely those won't be evaluated since that's actually the job of the shell (bash) whereas gnome-terminal, so it might help to create an actual script somewhere and tell gnome-terminal to use that.

  • Using /home/username/ instead of ~/ and it works. Thank you. Maybe there is a more flexible solution because of having to use lots of profiles for different Terminal layouts. – TravelTrader Jan 20 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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