Reputation: 720
Is there any package that I can use to copy one (or more) file/folder THEN paste into another directory? I am using Ubuntu, and I have the standard terminal + Terminator.
For example, I am looking for a functionality like:
Folder1$ COPY a.txt
Folder1$ cd ../Folder2
Folder2$ PASTE (a.txt -- optional)
Thank you! I just hate to keep referring to the whole path every time!
Upvotes: 2
Views: 7091
Reputation: 11
I just created a tool that can do this.
https://github.com/FynnSu/savepath
Use the sap command followed by a list of file paths (either relative or absolute) to add paths.
To use one of the saved paths just write pap followed by the command you want to use the path in and hit enter. You will then be prompted to confirm the command, and can use the arrow keys to modify the command: left/right moves the path insert location and up/down switches between different saved paths.
Upvotes: 1
Reputation: 65
Take a look at clipboard-files
here: https://github.com/larspontoppidan/clipboard-files
It uses xclip
to interface the desktop environment clipboard and provides handy commands like ccopy
and cpaste
that does exactly what was asked for here. As the desktop environment clipboard is used, the commands interact with the copy/pasting in file managers and other programs that use the clipboard for files. At least it works on Gnome-like desktops.
Full disclosure, I wrote the script after giving up finding something like it out there :)
Upvotes: 1
Reputation: 19
Here's my dumb way to do this, you can add them to your rcfile:
copy(){
test -z $1 && echo "No file input!" && return
test ! -e $1 && echo "File not exist!" && return
export orig_path="$PWD/$1"
export orig_name="$1"
}
paste(){
test -z $orig_path && echo "No copied file!" && return
if [ "$#" -lt 1 ];then
dist_name="$PWD/$orig_name"
if [ -d $orig_path ];then
cp -r $orig_path $dist_name
else
cp $orig_path $dist_name
fi
echo "$orig_name pasted."
else
dist_name="$PWD/$1"
if [ -d $orig_path ];then
cp -r $orig_path $dist_name
else
cp $orig_path $dist_name
fi
echo "\"$1\" pasted."
fi
}
This doesn't copy any data to the clipboard, since you want to do this only for not referencing folders, and this works for copying folder as well.
Upvotes: 1
Reputation: 1091
This terminal command should work for files:
cp a.txt ../Folder2/a.txt
And for folders:
cp -R myFolder ../Folder2/myFolder
Upvotes: 0