Running .sh file with one button click

I am a linux beginner and I am trying to automate a small task on my computer. In order to connect to my vpn, I have to open my terminal and type nordvpn connect
I have created a simple .sh script that does this for me.

#!/bin/bash
nordvpn connect

The problem is that to run this file I have to open my terminal and write `./vpn.sh
Is there a way I can automate this to be done with a single click?


Not sure about a click, but you could add a keyboard shortcut: Open Settings/Keyboard shortcuts, scroll to the bottom and press the plus sign. Give a name to your shortcut, enter /path/to/nordvpn connect as the command and then select a keyboard shortcut. Note: /path/to/nordvpn should be replaced by the output of which nordvpn.


To complement the very good alternative suggestion of Niclas Börlin to set up a shortcut key for this, I can add how the script can be set up to be run with a single mouse click, as originally asked.

You can create a .desktop launcher for the command. Such launcher will appear in your Application menu, from where you can pin it to the dock, providing one-click access.