You can cut, copy, and paste in CLI intuitively like the way you usually did in the GUI, like so:
cd to the folder containing files you want to copy or cut.
copy file1 file2 folder1 folder2 or
cut file1 folder1
- close the current terminal.
- open another terminal.
cd to the folder where you want to paste them.
To be able to do so, make sure you have installed
realpath. Then, append these functions to the end of your ~/.bashrc file:
# if the number of arguments equals 0
if [ $# -eq 0 ]
# if there are no arguments, save the folder you are currently in to the clipboard
pwd | xclip
# save the number of argument/path to `~/.numToCopy` file.
echo $# > ~/.numToCopy
# save all paths to clipboard
realpath -s "$@" | xclip
# mark that you want to do a copy operation
echo "copy" > ~/.copyOrCut
# use the previous function to save the paths to clipboard
# but mark it as a cut operation
echo "cut" > ~/.copyOrCut
# for every path
for ((i=1; i <= $(cat ~/.numToCopy); i++))
# get the nth path
pathToCopy="$(xclip -o | head -$i | tail -1)"
if [ -d "$pathToCopy" ] # If it's a directory
cp -r "$pathToCopy" .
cp "$pathToCopy" .
# if it was marked as a cut operation
if [ $(cat ~/.copyOrCut) = "cut" ]
# delete the original file
rm -r "$pathToCopy"
If you don't know what .bashrc file is and never modify it before, just open the file explorer, go to Home, press Ctrl+H (show hidden files), search for .bashrc and open it with a text editor like gedit.
By using the above script, you are overriding the default functionality of these commands:
copy is a reserved PostgreSQL command.
paste are reserved Linux command.
If you use one of those commands default functionality, just modify the script function names accordingly. For example, use
p instead of