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!
This terminal command should work for files:
cp a.txt ../Folder2/a.txt
And for folders:
cp -R myFolder ../Folder2/myFolder
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.
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 :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.