Question

When I want to execute a file, it seems that I always have to first 'cd' into that file's directory before executing it, unless it fails on a can't-find-my-dataz type error.

How can I get around typing two commands to just execute a program?

Example:

cd /usr/local/bin/minecraft/
java -Xms512M -Xmx2048M -jar minecraft.jar

How can I make that into one line, so as I can put it as my Exec=_ line when creating a custom launcher in Gnome3?

Was it helpful?

Solution

cd /usr/local/bin/minecraft/ && java -Xms512M -Xmx2048M -jar minecraft.jar should do it

OTHER TIPS

I am answering this question again with some extension so that others may find this useful.

cd /usr/local/bin/minecraft/ && java -Xms512M -Xmx2048M -jar minecraft.jar

This command will do for sure. But after running this command, you will stay in /usr/local/bin/minecraft/ directory. And, if you are using this command in a bash script, all the later commands will be executed in this directory.

If you want to run the command in your desired directory and get immediately back to where you were, enclose the command with parenthesis, i.e.,

(cd /usr/local/bin/minecraft/ && java -Xms512M -Xmx2048M -jar minecraft.jar)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top