Results 1 to 5 of 5

Thread: CLI for Gnome's trash?

  1. #1
    Join Date
    Jun 2008
    Location
    See avatar and user name
    Beans
    Hidden!
    Distro
    Ubuntu 12.10 Quantal Quetzal

    CLI for Gnome's trash?

    Hi *,

    does anybody know if there is a command-line interface to Gnome's trash, e.g. to put a file into the trash or to restore it via the command line?

    Thanks a lot in advance!
    Spelling mistakes are intended and meant to be amusing.

  2. #2
    Join Date
    Jun 2007
    Beans
    1,279
    Distro
    Ubuntu Development Release

    Re: CLI for Gnome's trash?

    Maybe just move files from and to ~/.local/share/Trash ?
    That's basically what the trash functionality of a desktop environment does...

  3. #3
    Join Date
    Jan 2007
    Location
    Netherlands
    Beans
    76
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: CLI for Gnome's trash?

    I use a small function to trash files and directories from the CLI.
    Just put this function in your .bashrc or your .zshrc

    Usage: trash <file's or directories>

    It will create a directory with today's date so you can find your files easily.

    Code:
    function trash() {
      if [ -z "$*" ] ; then
        echo "Usage: trash <file/dir>"
      else
        DATE=$( date +%F )
        [ -d "${HOME}/.local/share/Trash/files/${DATE}" ] || mkdir -p ${HOME}/.local/share/Trash/files/${DATE}
        for FILE in $@ ; do
          mv ${FILE} ${HOME}/.local/share/Trash/files/${DATE}
          echo "${FILE} trashed!"
        done
      fi
    }
    To restore I just move the file's from the trash to a new location.
    I can't remember where I found this function, so I don't know who deserves the credits.
    Registered Linux user #428992

  4. #4
    Join Date
    Jun 2008
    Location
    See avatar and user name
    Beans
    Hidden!
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: CLI for Gnome's trash?

    Thanks for the answers!

    I also found gvfs-trash, but this only moves a file into the trash (and updates ~/.locale/share/Trash/info).

    But I am looking for a more powerful command which also lists the trash content, restores files or clears the trash.

    I think it's a pity that the original path and the deletion time are stored in ~/.locale/share/Trash/info, but cannot be accessed easily. Or does Nautilus have a functionality I haven't found yet?
    Spelling mistakes are intended and meant to be amusing.

  5. #5
    Join Date
    Jun 2008
    Location
    See avatar and user name
    Beans
    Hidden!
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: CLI for Gnome's trash?

    Found it: sudo aptitude install trash-cli

    It ships with

    • trash
    • list-trash
    • restore-trash
    • empty-trash
    Spelling mistakes are intended and meant to be amusing.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •