11

I want to combine these two commands:

rvm use 1.9.2

and

redcar

and combine them to run as a standalone program. But when i created a launcher with these two commands inputted, separated by semicolon, it just doesn't work.

How to implement this function?

Frankel
  • 213

4 Answers4

15
sh -c "command 1 ; command 2"

did the job for me, directly as a launcher: just create a file and save it as program.desktop, then allow execution as a program (right click -> properties-> permissions -> allow executing as program)

[Desktop Entry]
Version=1.0
Name=ProgramName
Comment=This is my comment
Exec=sh -c "command 1 ; command 2"
Icon=/home/alex/Pictures/icon.png
Terminal=false
Type=Application
Categories=Utility;Application;
MikWind
  • 301
  • Yay! Your technique also works in the Alt+F2 launcher dialog. It would normally only execute at most one command, at least in LXDE. Now, sth. like sh -c "xeyes & xeyes" works. – tanius Oct 28 '15 at 01:18
  • Great! This also works for assigning multiple commands to a custom keyboard shortcut in 16.04 (for some reason, simply writing "command 1 ; command 2" doesn't work). –  Dec 18 '18 at 01:59
2

To use a command line program (tiff2pdf) I wanted a terminal with the program help, then an additional note about a related program (tiffcp), then a command prompt so I could use the program in the same terminal. I made an entry in the Gnome laucher of type Application (NOT Application in terminal!):

gnome-terminal -x bash -c "tiff2pdf -h; echo '** See also tiffcp'; exec bash"
kos
  • 35,891
Bruce
  • 21
  • 1
2
rvm use 1.9.2 && redcar

or

rvm use 1.9.2 || redcar

if the rvm-command fails, redcar is excecuted in the second example and not in the first example.

Thomas
  • 1,656
2

I'm not sure Gnome launcher supports this, but in a bash script a command like

program1; program2

means - start program1, then start program2 only after the first one terminates.

After some testing I think the most robust thing would be to create a simple script:

#!/bin/sh
rvm use 1.9.2 &
redcar &

set the executable bit on it and then create a launcher which starts this script, i.e. /home/yourusername/start_redcar.sh

As a bonus - if you create a directory called "bin" in your home folder, put the script there and name it "start_redcar", you'll be able to start it from terminal or from the "Run a command" window which opens when pressing Alt-F2 - by simply typing the command name

Sergey
  • 43,665