Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm still very new to Ubuntu. I'm using 12.04, and I'd like to know if there is a way to run this program/shell script without typing:

/opt/idea/bin/idea.sh

It's kinda tedious and I'm quite lazy. Any help would be appreciated. Thanks.

share|improve this question

3 Answers 3

You can add /opt/idea/bin to your PATH variable:

PATH=/opt/idea/bin:"$PATH"

After this you can run it with simply idea.sh.

You probably want to add this line in your .bash_profile.

share|improve this answer
1  
also: if you make the script executable, the .sh extension can be left away (assuming you use the shebang at the top of the script). simply "idea" is enough then. –  Jacob Vlijm Mar 1 at 8:24
1  
@Jacob: you cannot leave off the extension, as that is part of the executable's file name (this isn't Windows, where magic like that causes other issues). In order to call the script with the name idea, you would have to create a link or alias with that name pointing at the idea.sh script. –  Jonathan Callen Mar 1 at 13:25
    
@JonathanCallen Callen you certainly can! make the script executable, remove the .sh extension from both the filename and the command to run it, given the fact that you start the script with the shebang #!/bin/bash. –  Jacob Vlijm Mar 1 at 15:25
1  
@Jacob what I mean is without renaming the file, you cannot (and it appears this is part of a larger software package, so you shouldn't just rename files) –  Jonathan Callen Mar 1 at 21:29
    
@JonathanCallen Hi Jonathan, I cannot see the context of this script, but in general, if it is a "main" file, or a script to call another main application file (which it is I guess, otherwise there would be no reason to call it from the user interface) it is concidered bad practice to use the language extension. –  Jacob Vlijm Mar 1 at 21:39

You can create a launcher by using following command:

gnome-desktop-item-edit --create-new <path-where-to-save>. I t will open this window.

enter image description here

Name it whatever you like and in command box type following

sh -c '/opt/idea/bin/idea.sh' and save it.

Now you can run that file using newly created launcher

OR

You can create a .desktop file with following contents

[Desktop Entry]
Name=<whatever-you-want>
Exec=sh -c '/opt/idea/bin/idea.sh'     
Terminal=false
Type=Application
Icon='<path to an icon file if you want>'

Now save it with .desktop extension on any place.

Make it executable with this command chmod a+x <your-desktop-file>

Now double click to open it.

share|improve this answer

We can also run /opt/idea/bin/idea.sh file directly using bash_aliases

Open ~/.bashrc file by running,

gedit ~/.bashrc

Remove the # before the lines and save it, so that the lines will look like,

enter image description here

Now open ~/.bash_aliases file,

gedit ~/.bash_aliases

Add the below lines in that file and save it,

alias idea='cd /opt/idea/bin && sudo ./idea.sh'

Finally source the ~/.bashrc file,

source ~/.bashrc

Now you can run /opt/idea/bin/idea.sh file directly by,

idea
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.