2

Usually, before beginning my coding duty I open the following:

  • google-chrome
  • nautilus
  • terminal
  • system monitor
  • gedit

Is there a way to open all of them with a single terminal command?

I use Ubuntu 18.04.

rsaavedra
  • 163
  • 6

3 Answers3

2

Here's what I'd do:

for i in google-chrome nautilus gnome-terminal gedit ; do
    setsid "$i" >  /dev/null 2>&1 
done

setsid or nohup can be used to daemonize a process, with setsid being preferred because it starts each process as new session leader, effectively disconnecting it from terminal. See also, Difference between nohup, disown and &.

As for > /dev/null 2>&1 that just sends both normal and error streams from each program into /dev/null so that you can still use terminal normally. See also What does & mean exactly in output redirection? and What is the differences between &> and 2>&1

I don't remember command for system monitor off the top of my head, so I'll leave that up to you.

Feel free to turn this loop into either a function that can live in your ~/.bashrc or make a full-blown scripts. Up to you.

dessert
  • 39,392
  • 12
  • 115
  • 163
Sergiy Kolodyazhnyy
  • 103,293
  • 19
  • 273
  • 492
1

Simplest way is to make a bash script with all the needed commands to start those programs.

You could even put that script in Startup Applications so it gets run on every bootup.

dessert
  • 39,392
  • 12
  • 115
  • 163
fixit7
  • 2,776
  • 3
  • 30
  • 70
  • Not gonna work, unless you start each in background. Each command blocks script execution until it exists. Only then next one runs. So launch it in background with appending `&` to the end. – Sergiy Kolodyazhnyy May 30 '18 at 03:53
  • I tested it using using firefox and mate-terminal with no problems. I am assuming your "exists" should be exits. – fixit7 May 30 '18 at 03:59
  • Yes. Typing on phone is prone to typos. And how did you structure the script ? – Sergiy Kolodyazhnyy May 30 '18 at 04:01
  • #!/bin/bash # Ubuntu_Mate 16.04 LTS mate-terminal firefox – fixit7 May 30 '18 at 04:01
  • The mate-terminal has `#` in front, which tells me it's commented out. Your script only runs `firefox`. What should be done is `firefox &`. Then on next line `mate-terminal &`. And so on and so forth. – Sergiy Kolodyazhnyy May 30 '18 at 04:04
  • No command is commented out. Only comment is for Ubuntu version. Mate-terminal and firefox are on separate lines. There are often multiple ways of accomplishing the same thing. – fixit7 May 30 '18 at 04:05
  • Alright. Apparently `mate-terminal` launches itself in background. In general however thia shouldn't happen. As I said, scripts are sequential, and each program blocks execution. – Sergiy Kolodyazhnyy May 30 '18 at 04:10
1

To open all of the above applications at one, you could execute something like this:

chromium ; nautilus ; gnome-terminal ; gnome-system-monitor ; gedit

To make this startup every time you Log In, you could put this command into a .desktop file on the Exec= line.

Place this file into /usr/share/applications and open gnome-session-properties. Simply add your new application to the current list of startup applications. This should do the trick.