Terminal's command shortcut

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
knob
Level 2
Level 2
Posts: 83
Joined: Sat Nov 19, 2016 3:53 pm

Terminal's command shortcut

Post by knob »

Good morning !

Does anyone knows a way to create a terminal's command shortcut based on CONTROL+V contents ?

for example .... if i have "127.0.0.1" copied ( thru control+C ), how could i code a script to lunch a terminal with the command "ping 127.0.0.1" ??

Thanks !

ciniset
Level 2
Level 2
Posts: 61
Joined: Thu Dec 28, 2017 10:14 am

Re: Terminal's command shortcut

Post by ciniset »

Code: Select all

sudo apt install xsel
For a desktop launcher
====================
1. make a desktop launcher (right click on desktop -> Create a new launcher here)
In name put whatever you want . in command put:
sh -c "ping $(xsel -b)"
and check "Launch in terminal"
2. Copy needed IP or domain name in terminal and double click on desktop launcher

For a script
==========
(just an example, you have to modify it in accordance with your needs)
Copy and paste the code into "test" file located on ~/Desktop

Code: Select all

#!/bin/bash
ping $(xsel -b)
exit 0
Than in terminal:

Code: Select all

cd ~/Desktop
chmod +x test
Copy needed IP or domain name in clipboard (CTRL+C)
in terminal:

Code: Select all

./test
:)

Post Reply

Return to “Newbie Questions”