Although you have already found a solution that you can double click on, there's a solution that makes it more trivial to run from command line:
Step 1 - Write a script
This is already covered by an answer of LeonidMew, i will copy it here:
#!/bin/bash
cd ~/MyDirectory
./myapp +some arguments
and then
chmod u+x scriptname
Step 2 - Make it easy to execute
You need to create a directory ~/bin
and make bash search it for commands. So in terminal we write:
mkdir ~/bin
mv scriptname ~/bin
vim ~/.profile
Here i am doing everything in terminal, you can of course create a directory dir
in your home directory and also move your script there via graphical tools that you are comfortable with. Also i am using vim as an editor, but it is a little difficult for beginners to use, i would advise you to learn, but you can just use a different editor (even graphical) to edit .profile
inside your home directory, note that this file is hidden by default.
You need to add the following to an end of that file
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
If you are using vim you press i to start adding text, and then Esc to end adding. After that you input :wq
to write file and exit. Or, as i have already said, use a more simple editor.
Step 3 - Enjoy
Now, it will not matter what directory you are in, you can always just type scriptname
and press Enter. You can also place other scripts and applications that you want to be executable in ~/bin
.