How to Add a `Paste Link Here` Nemo Action

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Locked
dkebler
Level 1
Level 1
Posts: 26
Joined: Thu Aug 07, 2014 2:48 pm

How to Add a `Paste Link Here` Nemo Action

Post by dkebler »

TLDR;
requirements: must install xclip and xdotool,

Code: Select all

sudo apt install xclip xdotool

1. Download and extract latest release https://github.com/dkebler/paste-link-here/releases into

Code: Select all

 ~/.local/share/nemo/actions
.
2. Make sure the two bash scripts (.sh) have executable permissions.
3. In Nemo select a file or directory, then right click and select

Code: Select all

 Link to Clipboard
4. Navigate to your desired destination folder, make sure nothing is selected. Right Click and select

Code: Select all

Paste Link Here
Have fun. Only tested in fresh install on 19.1. No warranties of nada including crashing nemo or mint. Scripts have a commented echo debug line you can uncomment to get a log file if you have issues.

Provided as is...it's working for me so sorry don't have time to troubleshoot your issues (if any).

---- back story

In other OS there has been this nice feature where one could copy a file and then paste it as a link in another directory all from the context menu.
In several posts here and elsewhere I have seen requests for this (downright begging)

The current `Make Link` is fine except it has two shortcomings.
1. it puts the link in the same directory from which you must move it to where you want.
2. It adds a 'Link to' preface which most time the user will need to remove once they move the link. This is done so that it doesn't conflict with existing file being as the link will be placed in the same directory.

So after to putting a little thought to this I have come up with a couple nemo actions and couple bash scripts that does the trick!
Last edited by dkebler on Mon Jan 21, 2019 1:14 am, edited 1 time in total.
dkebler
Level 1
Level 1
Posts: 26
Joined: Thu Aug 07, 2014 2:48 pm

Re: How to Add a `Paste Link Here` Nemo Action

Post by dkebler »

Here is code of two bash scripts called by the two nemo actions
see github repo https://github.com/dkebler/paste-link-here

copies the currently selected file or directory path to the clipboard

Code: Select all

#!/bin/bash
LINK_DIR=$(dirname $1)
#echo The Link Path- $1 - was sent to clipboard > $LINK_DIR/link.log
echo $1 | /usr/bin/xclip -se c
grabs path in clipboard and current directory and makes a link - needs to reload after making link for it to be seen

Code: Select all

#!/bin/bash
LINK_PATH=$(/usr/bin/xclip -o -se c)
LINK_NAME=$(basename "${LINK_PATH}")
#echo Link Path=$LINK_PATH, Link Name=$LINK_NAME, Link Destination $1 > $1/link.log
ln -s $LINK_PATH $1/$LINK_NAME
$(xdotool key ctrl+r)
guts of 'link to clipboard' action

Code: Select all

Name=Link to Clipboard
Exec=<./path2clip.sh %F>
Selection=s
Extensions=any;
guts of the paste link here action

Code: Select all

Name=Paste Link Here
Exec=<./clip2link.sh %P>
Selection=none
Extensions=dir;none
Last edited by dkebler on Mon Jan 21, 2019 1:03 am, edited 3 times in total.
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: How to Add a `Paste Link Here` Nemo Action

Post by smurphos »

Nice - I'm planning to add make a little github repo of useful Cinnamon scripts and actions at some point - any objection if I include this (or a modification of it) with accreditation?
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
dkebler
Level 1
Level 1
Posts: 26
Joined: Thu Aug 07, 2014 2:48 pm

Re: How to Add a `Paste Link Here` Nemo Action

Post by dkebler »

most definitely. Maybe I'll just make a github repo and you can embed, fork or reference that.

I probably end up making a few improvements and some error checking like checking to make sure the clipboard is holding a valid file/directory to link and the paste target is also a valid directory.
dkebler
Level 1
Level 1
Posts: 26
Joined: Thu Aug 07, 2014 2:48 pm

Re: How to Add a `Paste Link Here` Nemo Action

Post by dkebler »

Already fixed an issue of not handling spaces in filenames or directory path.

Updated archive at download link above and github repo will alway hold the latest
https://github.com/dkebler/paste-link-here

latest release as zip or tar.gz here
https://github.com/dkebler/paste-link-here/releases
redlined

Re: How to Add a `Paste Link Here` Nemo Action

Post by redlined »

this is awesome, dkebler, thanks for sharing!
reading up on the action directory, real cool 8) and another nemo nitpick crossed off the list :mrgreen:

(works as expected LM19.1 Cinnamon4.0.9)
dhunter

Re: How to Add a `Paste Link Here` Nemo Action

Post by dhunter »

Another "thanks very much" for this. Is particularly important for those of us who use FAT32/NTFS partitions to work across OS's, since the regular Nemo "Make Link" thing won't work, since it can't place a link on the FAT32/NTFS volume to be moved in the first place. Since this doesn't have that weakness, here's hoping your solution, (or at least the logic behind your solution) ends up getting incorporated as a full replacement for "Make Link" someday. Thanks again!
Locked

Return to “Tutorials”