Skip to content

Instantly share code, notes, and snippets.

@Kyrremann
Created July 12, 2012 11:58
Show Gist options
  • Save Kyrremann/3097709 to your computer and use it in GitHub Desktop.
Save Kyrremann/3097709 to your computer and use it in GitHub Desktop.
Copy and move files similar to copy/paste in a file manager
# copyfile
copyfile() {
local files="";
local path="$PWD";
for var in $@;
do
files="${files} ${path}/${var}";
done;
echo ${files} | xclip;
}
# pastfile
pastefile() {
local path="$PWD";
local from=`xclip -o`;
if [ -d $file ];
then
cp -R $from $path;
else
cp $from $path;
fi;
}
# movefile
movefile() {
local path="$PWD";
local from=`xclip -o`;
mv $from $path;
}
# cutfile
cutfile() {
local files="";
local tmp_files="";
local path="$PWD";
for var in $@;
do
if [ -d /tmp/$var ];
then
rm -R /tmp/$var;
fi;
files="${files} ${path}/${var}";
tmp_files="${tmp_files} /tmp/${var}";
done;
mv ${files} /tmp/;
echo ${tmp_files} | xclip;
}
@Kyrremann
Copy link
Author

Fixed both bugs!

  1. You can not copy multiple single files. So "copyfile file1 file2" does not work.
  2. You can not use cutfile on files with the same name in a row, then there will be duplicates in the /tmp /

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment