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've added the following line to the .bashrc file:

alias midos="sh /home/erkanmdr/Belgeler/midos/midos.sh"

This command works fine in the terminal and tty. But not working in my .desktop shortcut file.

midos.desktop file:

[Desktop Entry]
Name=MiDoS
Exec=midos
Icon=/home/erkanmdr/Belgeler/midos-128.png
Terminal=true

How do I execute my midos command in the .desktop shortcut file?

share|improve this question
    
You can just substitute Exec=midos with Exec=sh /home/erkanmdr/Belgeler/midos/midos.sh –  c0rp Jul 16 at 15:55
    
I do not want it. I want to use directly. Its possible? –  ErkanMDR Jul 16 at 15:57
1  
I'd replace sh with bash (alias midos="bash /home/erkanmdr/Belgeler/midos/midos.sh") –  Sylvain Pineau Jul 16 at 15:57
    
@SylvainPineau not worked –  ErkanMDR Jul 16 at 16:10

3 Answers 3

up vote 15 down vote accepted

While the other answers offer a good workaround for your problem, to answer your question, the right way to use an alias inside a .desktop file is, in your case:

Exec=bash -ic "midos"

That's because aliases from ~/.bashrc file will work only in a bash interactive shell (-i option is used in this case to start bash interactive).

If another user wants to use the same .desktop file, then he must to have defined as well that alias.

share|improve this answer
    
Great! Exactly what I was looking for. Thank you very much –  ErkanMDR Jul 17 at 12:01

I would be extremely surprised if the GUI has any idea about your shell. You should put the full path in your desktop file:

Exec=/home/erkanmdr/Belgeler/midos/midos.sh

And make sure that your script is executable.

share|improve this answer

Little workaround.

Add this #!/bin/bash to the first line of your script, if it is not there already.

For example your script before:

sometext1
sometext2
sometext3
sometext4

You script after:

#!/bin/bash
sometext1
sometext2
sometext3
sometext4

Now copy your script to /usr/local/bin, and make it executable:

sudo cp /home/erkanmdr/Belgeler/midos/midos.sh /usr/local/bin/midos
sudo chmod +x /usr/local/bin/midos

After that it should work as you want.

share|improve this answer
    
Yes! Its worked. Thanks –  ErkanMDR Jul 16 at 17:03

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.