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?

1
  • Why don't you accept an answer? Jul 26, 2019 at 6:46

4 Answers 4

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;
2
  • 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, 2015 at 1: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).
    – user606179
    Dec 18, 2018 at 1:59
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.

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

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"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .