68

Im trying to make a shortcut to login my ssh server:

ssh x.x.x.x

I made the following file:

ssh_home.sh

Made it executable:

sudo chmod +x ./ssh_home

Checked by right clicking properties to check if it was executable and it was..

But whatever I do, when double clicking it, it will launch gedit. I tried "Open With" but no terminal app is shown there. I searched the net but only found a way to link to the file while not integrating it in one "shortcut file"

kiri
  • 28,246
  • 16
  • 81
  • 118
michel
  • 697
  • 1
  • 5
  • 4

6 Answers6

61

I think it would be better to use a launcher file for your script by creating a ~/Desktop/ssh_home.desktop file with the following contents:

[Desktop Entry]
Version=1.0
Exec=/home/yourname/bin/ssh_home.sh
Name=SSH Server
GenericName=SSH Server
Comment=Connect to My Server
Encoding=UTF-8
Terminal=true
Type=Application
Categories=Application;Network;

That way you will have a clickable icon which will launch your script.

You may have to also set the executable flag with chmod:

chmod +x ~/Desktop/ssh_home.desktop
Cyril Laury
  • 956
  • 6
  • 6
57

I know this is a while ago but though if someone else asks I have this answer.

  1. Open nautilus
  2. Files menu -> behaviour tab
  3. Run executable text files when they are opened

In later versions this option is found at: Files menu -> Edit -> Preferences -> behaviour tab

In Ubuntu 14.10 move the mouse to the top of the screen and the File, Edit etc... Menu bar appears. Click EDIT -> Preferences -> Behaviour tab

muru
  • 197,895
  • 55
  • 485
  • 740
Peter
  • 709
  • 5
  • 6
3

The "trap" for me was that I searched via right-clicking on the file for a way to change the behaviour (to have a script run instead of opened in gedit). Don't right-click ! Rather open from the "regular" menu-bar:

Edit-Preferences-Behaviour and change to "run" or "ask each time".

Comment: For my taste there should be a way to run a program via right-clicking too. Especially since right-clicking leads to the menu "open with", which makes you search for "open with bash", however "bash" is not included as an option...

1

imo the simplest answer is -

  1. Check that the .sh file works if clicked or run from its own directory.
  2. If it works there, right-click on it in Files aka Nautilus, select 'Make Link'
  3. This produces a file named 'link to xxxx.sh' in the same directory
  4. Drag this onto the desktop
  5. Rename it how you wish eg clean off 'link to' and 'sh', just leave the name, it will still work.
muru
  • 197,895
  • 55
  • 485
  • 740
  • Also you can change the icon of the link too. Right-click it, select Properties, click the default icon in the upper left part of the properties window, and so just navigate until you find the image your want to be the icon. – Brian Hellekin May 24 '17 at 04:07
1

I'd say the easiest way to add a shell script to the shortcuts would be to add the .sh file to the home directory. Once copied to the home directory just go to custom shortcuts and add the command sh yourfile.sh

This was my work around hope it helps you

0

Ubuntu 20.04

open file manager (aka Nautilus) click hamburger menu, top right (three horizontal bars) choose Preferences click Behaviour tab under Executable Text Files, choose your preference. (Ask What to do lets you choose each time and file)