{"id":13484682,"url":"https://github.com/andreafrancia/trash-cli","last_synced_at":"2025-05-13T23:08:09.105Z","repository":{"id":1818768,"uuid":"2742985","full_name":"andreafrancia/trash-cli","owner":"andreafrancia","description":"Command line interface to the freedesktop.org trashcan.","archived":false,"fork":false,"pushed_at":"2025-03-12T10:59:16.000Z","size":2472,"stargazers_count":3880,"open_issues_count":65,"forks_count":182,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-05-12T14:11:18.417Z","etag":null,"topics":["linux","python","trashcan"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jdg/MBProgressHUD","license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreafrancia.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.txt","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-11-09T17:06:36.000Z","updated_at":"2025-05-12T14:00:32.000Z","dependencies_parsed_at":"2023-10-01T16:13:53.202Z","dependency_job_id":"7f23eb01-a65e-4f81-aad2-43d2e745bdb9","html_url":"https://github.com/andreafrancia/trash-cli","commit_stats":{"total_commits":1926,"total_committers":57,"mean_commits":33.78947368421053,"dds":0.4932502596053998,"last_synced_commit":"667bab07e76a881ff4b281fbc1e891d3771de338"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafrancia%2Ftrash-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafrancia%2Ftrash-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafrancia%2Ftrash-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreafrancia%2Ftrash-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreafrancia","download_url":"https://codeload.github.com/andreafrancia/trash-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254041486,"owners_count":22004731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","python","trashcan"],"created_at":"2024-07-31T17:01:29.848Z","updated_at":"2025-05-13T23:08:04.083Z","avatar_url":"https://github.com/andreafrancia.png","language":"Python","readme":"trash-cli - Command Line Interface to FreeDesktop.org Trash.\n============================================================\n\n|Downloads|\n\n|Donate|_\n\n`简体中文`_\n\ntrash-cli trashes files recording the original path, deletion date, and \npermissions. It uses the same trashcan used by KDE, GNOME, and XFCE, but you \ncan invoke it from the command line (and scripts).\n\nIt provides these commands::\n\n    trash-put           trash files and directories. \n    trash-empty         empty the trashcan(s).\n    trash-list          list trashed files.\n    trash-restore       restore a trashed file.\n    trash-rm            remove individual files from the trashcan.\n\nUsage\n-----\n\nTrash a file::\n\n    $ trash-put foo\n\nList trashed files::\n\n    $ trash-list\n    2008-06-01 10:30:48 /home/andrea/bar\n    2008-06-02 21:50:41 /home/andrea/bar\n    2008-06-23 21:50:49 /home/andrea/foo\n\nSearch for a file in the trashcan::\n\n    $ trash-list | grep foo\n    2007-08-30 12:36:00 /home/andrea/foo\n    2007-08-30 12:39:41 /home/andrea/foo\n\nRestore a trashed file::\n    \n    $ trash-restore\n    0 2007-08-30 12:36:00 /home/andrea/foo\n    1 2007-08-30 12:39:41 /home/andrea/bar\n    2 2007-08-30 12:39:41 /home/andrea/bar2\n    3 2007-08-30 12:39:41 /home/andrea/foo2\n    4 2007-08-30 12:39:41 /home/andrea/foo\n    What file to restore [0..4]: 4\n    $ ls foo\n    foo\n    \nRestore a trashed file while overwriting existing files::\n    \n    $ echo \"original\"\u003efoo\n    $ ls\n    foo\n    $ trash foo\n    $ echo \"new\"\u003efoo\n    $ trash-restore --overwrite\n    0 2022-11-01 22:15:00 /home/andrea/foo\n    What file to restore [0..0]: 0\n    $ cat foo\n    original\n\nRestore multiple trashed files separated by ',', also support range::\n\n    $ trash-restore\n    0 2007-08-30 12:36:00 /home/andrea/foo\n    1 2007-08-30 12:39:41 /home/andrea/bar\n    2 2007-08-30 12:39:41 /home/andrea/bar2\n    3 2007-08-30 12:39:41 /home/andrea/foo2\n    What file to restore [0..3]: 0-2, 3\n    $ ls foo bar bar2 foo2\n    foo bar bar2 foo2\n\nRemove all files from the trashcan::\n\n    $ trash-empty\n\nRemove only the files that have been deleted more than \u003cdays\u003e ago::\n    \n    $ trash-empty \u003cdays\u003e\n\nExample::\n\n    $ date\n    Tue Feb 19 20:26:52 CET 2008\n    $ trash-list\n    2008-02-19 20:11:34 /home/einar/today\n    2008-02-18 20:11:34 /home/einar/yesterday\n    2008-02-10 20:11:34 /home/einar/last_week\n    $ trash-empty 7\n    $ trash-list\n    2008-02-19 20:11:34 /home/einar/today\n    2008-02-18 20:11:34 /home/einar/yesterday\n    $ trash-empty 1\n    $ trash-list\n    2008-02-19 20:11:34 /home/einar/today\n\nRemove only files matching a pattern::\n\n    $ trash-rm \\*.o\n\nNote: you need to use quotes in order to protect the pattern from shell expansion.\n\nFAQ\n---\n\nHow to create a top level .Trash dir?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSteps ::\n\n    sudo mkdir --parent /.Trash\n    sudo chmod a+rw /.Trash\n    sudo chmod +t /.Trash\n\nCan I alias `rm` to `trash-put`?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can but you shouldn't. In the early days I thought it was a good idea to do\nthat but now I changed my mind. \n\nAlthough the interface of `trash-put` seems to be compatible with `rm`, it has\ndifferent semantics which will cause you problems. For example, while `rm`\nrequires `-R` for deleting directories `trash-put` does not.\n\nBut sometimes I forget to use `trash-put`, really can't I?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou could alias `rm` to something that will remind you to not use it::\n\n    alias rm='echo \"This is not the command you are looking for.\"; false'\n\nThen, if you really want to use `rm`, simply prepend a backslash to bypass the\nalias::\n\n    \\rm file-without-hope\n\nNote that Bash aliases are used only in interactive shells, so using \nthis alias should not interfere with scripts that expect to use `rm`.\n\nWhere the trashed files go?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\nFile trashed from the home partition will be moved here::\n\n    ~/.local/share/Trash/\n\nHow to auto delete files older that 30 days?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nRun this::\n\n    (crontab -l ; echo \"@daily $(which trash-empty) 30\") | crontab -\n\nThis will update your crontab file with a `trash-empty` command that runs daily\nand removes files older than 30 days. To review your crontab use: `crontab -l`\n\nInstallation\n------------\n\nThe easy way\n~~~~~~~~~~~~\n\nRequirements:\n * Python 3 (Python 2.7 also work)\n * pipx_ (optional, to install in a clean environment)\n\nIf pipx is available::\n\n    pipx install trash-cli\n\nAlternatively, install with vanilla pip::\n\n    pip install trash-cli\n\nNote: you may want add ~/.local/bin to the PATH::\n\n    echo 'export PATH=\"$PATH\":~/.local/bin' \u003e\u003e ~/.bashrc\n    source ~/.bashrc # reload .bashrc\n\nFor uninstalling use::\n\n    pipx uninstall trash-cli\n\nor::\n\n    pip uninstall trash-cli\n\nBleeding Edge (from sources)\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nFirst of all you need to uninstall any previous version of trash-cli::\n\n    $ [sudo] pip uninstall trash-cli # remove the previous version (with pip)\n    $ [sudo] apt-get remove trash-cli # remove the previous version (with apt)\n    $ [sudo] yum uninstall trash-cli # remove the previous version (with yum)\n    $ ... # refer to the package manager of your distribution\n\nThen install the latest version from git::\n\n    $ [sudo] pip install git+https://github.com/andreafrancia/trash-cli\n\nAfter the user installation you may want add this line to your .bashrc/.zshrc::\n\n    export PATH=~/.local/bin:\"$PATH\"\n\nFrom package manager\n~~~~~~~~~~~~~~~~~~~~\n\nDebian/Ubuntu (apt)::\n\n    sudo apt install trash-cli\n\nArch Linux (pacman)::\n\n    sudo pacman -S trash-cli\n\nFedora (dnf)::\n\n    sudo dnf install trash-cli\n\nInstall shell completions\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou need install by::\n\n    pipx install 'trash-cli[completion]'\n\nor::\n\n    pip install 'trash-cli[completion]'\n\nThen::\n\n    cmds=(trash-empty trash-list trash-restore trash-put trash)\n    for cmd in ${cmds[@]}; do\n      $cmd --print-completion bash | sudo tee /usr/share/bash-completion/completions/$cmd\n      $cmd --print-completion zsh | sudo tee /usr/share/zsh/site-functions/_$cmd\n      $cmd --print-completion tcsh | sudo tee /etc/profile.d/$cmd.completion.csh\n    done\n\nBugs\n----\n\nIf you discover a bug please report it here:\n\n    https://github.com/andreafrancia/trash-cli/issues\n\nFeedback\n--------\n\nYou can send me an email using andrea@andreafrancia.it.\n\nDevelopment\n-----------\n\nEnvironment setup::\n\n    python -m venv .venv\n    source .venv/bin/activate\n    pip install -r requirements-dev.txt -r requirements.txt\n\nRunning tests::\n\n    pytest -m 'not slow'        # run only fast tests\n    pytest -m 'slow'            # run slow tests\n    pytest                      # run all tests\n\nThanks\n------\nThanks to Paypal donors.\n\nThanks to `project contributors`_.\n\nThanks to `JetBrains`_ for their license for Open Source Development\n\n.. |Downloads| image:: https://img.shields.io/pypi/dm/trash-cli\n.. |Donate| image:: https://www.paypalobjects.com/en_GB/i/btn/btn_donate_SM.gif\n.. _Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=93L6PYT4WBN5A\n.. _简体中文: https://github.com/andreafrancia/trash-cli/blob/master/README_zh-CN.rst\n.. _project contributors: https://github.com/andreafrancia/trash-cli/graphs/contributors\n.. _JetBrains: https://jb.gg/OpenSource\n.. _pipx: https://pypa.github.io/pipx/\n","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=93L6PYT4WBN5A"],"categories":["Python","Uncategorized","Hacks"],"sub_categories":["Uncategorized","Plugin manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreafrancia%2Ftrash-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreafrancia%2Ftrash-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreafrancia%2Ftrash-cli/lists"}