3

I'd like to perform certain actions by keyboard shortcut on Linux Mint 17.3. Specifically, I'd like to execute commands

expressvpn connect (connecting to my VPN provider)

and

xsel -b|xsel -bi (strips formatting from whatever text is copied to clipboard)

Both commands work fine when I open Terminal and type them in. But when I try to work them into shortcuts in the Keyboard settings, no luck. I've tried

gnome-terminal -e "xsel -b|xsel -bi"

and

gnome-terminal -e "expressvpn connect"

to no avail. These won't work when typed to Terminal, either.

I understand from previous answers that -e doesn't like spaces; so how do I get these commands to work?

3
  • do you have to do this with a a keyboard shortcut (in Keyboard settings), or would a shell alias be acceptable?
    – Jeff Schaller
    Commented Apr 20, 2016 at 13:42
  • I'm more than open for any suggestions on how to achieve the goals :). Sorry to say but my Linux expertise is minimal and my command line expertise tends to date from the good old days of MS-DOS 4.0 :).
    – jmkorhonen
    Commented Apr 20, 2016 at 13:47
  • If any of the existing answers solves your problem, please consider accepting it via the checkmark. Thank you!
    – Jeff Schaller
    Commented Apr 23, 2017 at 12:45

2 Answers 2

3

Put the commands you want to run in individual scripts and then create keyboard shortcuts to run the scripts. The clipboard formatting example would look like this.

#!/bin/bash
xsel -b|xsel -bi

If you save that file in ~/scripts/strip-format.sh you'll need to give it executable permissions with chmod +x ~/scripts/strip-format.sh and then add your custom shortcut. Make sure you use the full path to the script. In the screenshot replace $USER with your username.

enter image description here

After you add the shortcut give it a keyboard combo and it should run in the background.

0

You could make aliases for these instead of keyboard shortcuts. On the assumption that you are using the default shell (bash), edit your ~/.bash_profile and add these lines:

alias sf='xsel -b | xsel -bi'
alias vpn='expressvpn connect'

where you can change the names from 'sf' and 'vpn' to whatever you want. Run . ~/.bash_profile in a terminal window (or copy/paste the same alias lines into the shell window directly) to begin using them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .