Title: Extend support for the file-system recycle bin / trash · Issue #6801 · PowerShell/PowerShell · GitHub
Open Graph Title: Extend support for the file-system recycle bin / trash · Issue #6801 · PowerShell/PowerShell
X Title: Extend support for the file-system recycle bin / trash · Issue #6801 · PowerShell/PowerShell
Description: #6778 tracks porting the Clear-RecycleBin cmdlet to PowerShell Core, and it would be helpful to support other recycle-bin/trash-related functionality too, notably the ability to move filesystem items there. Note: Windows calls the transi...
Open Graph Description: #6778 tracks porting the Clear-RecycleBin cmdlet to PowerShell Core, and it would be helpful to support other recycle-bin/trash-related functionality too, notably the ability to move filesystem ite...
X Description: #6778 tracks porting the Clear-RecycleBin cmdlet to PowerShell Core, and it would be helpful to support other recycle-bin/trash-related functionality too, notably the ability to move filesystem ite...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/6801
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Extend support for the file-system recycle bin / trash","articleBody":"#6778 tracks porting the `Clear-RecycleBin` cmdlet to PowerShell Core, and it would be helpful to support other recycle-bin/trash-related functionality too, notably the ability to move filesystem items there.\r\n\r\nNote:\r\n\r\n* Windows calls the transient storage area for deleted-via-File Explorer files and folders the _recycle bin_. In the world of macOS and Linux, the same concept is known as the _trash_. \r\nAs a real-world metaphor _trash_ makes more sense, because recovering an item from this storage area is not an act of _recycling_. \r\nThe rest of this post uses the term _trash_, but it's worth creating _aliases_ so as to offer command and parameter names familiar on all supported platforms.\r\n\r\n* In the Linux world, only distros with freedesktop.org-compliant desktop environments have a [standardized trash interface](https://specifications.freedesktop.org/trash-spec/trashspec-latest.html), most easily accessibly via CLIs, as shown in #6778.\r\n\r\n### Support for moving (sending) filesystem items to the trash\r\n\r\n[As suggested by @geelaw](https://github.com/PowerShell/PowerShell/issues/6743#issuecomment-385472864), we could add a `-ToRecycleBin` / `-ToTrash` switch to the FileSystem provider's implementation of the `Remove-Item` cmdlet.\r\n\r\n@iSazonov suggests complementing the new switch with a _preference variable_ that sends items to the trash _by default_. \r\nThe alternative is to use the generic `$PSDefaultParameterValues` mechanism: \r\n`$PSDefaultParameterValues['Remove-Item:ToTrash']=$True`\r\n\r\n### Support for recovering items from the trash.\r\n\r\nProgrammatically recovering items from the trash is nontrivial and the question is whether _programmatic_ support for it is needed at all (say, via a `Recover-Item` cmdlet).\r\n\r\n@geelaw's thoughts:\r\n\r\n> One possible way for this is to let the cmdlet return a set of recycled items, where each item has an identifier (consistent across invocations but platform-dependent), date of removal, restoration path (sometimes might be unavailable) etc., and another cmdlet would restore items. I would suggest not having such cmdlets.\r\n\r\nThere's also the issue of feasibility - do all platforms have enough API / CLI support to support such a cmdlet? \r\nOn Windows, we can use `(New-Object -ComObject Shell.Application).NameSpace(0xA).Items()`\r\n\r\n### Support for opening the trash-folder GUI\r\n\r\nRecovering items from the trash is typically done interactively, via the platform's file manager's GUI.\r\n\r\nA cmdlet such as `Show-RecycleBin` / `Show-Trash` could facilitate that.\r\n\r\nThat said, perhaps such functionality doesn't add enough value to warrant implementation as a cmdlet, given that users can simply use the respective platform's GUI file manager and, as @geelaw points out, GUI-focused cmdlets are rare in PowerShell (and are typically only useful in command-line use).\r\n\r\nEnvironment data\r\n----------------\r\n\r\nWritten as of:\r\n\r\n```powershell\r\nPowerShell Core v6.0.2\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2018-05-02T12:25:34Z","url":"https://github.com/PowerShell/PowerShell/issues/6801"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a4cd5ae8-73d1-69e2-5907-4555723b514f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA58:1EA4D5:127F3A:19093B:6AFD4C62 |
| html-safe-nonce | 7b7930f6a8903e7bd67cad34e36f21cc6cec7f6a3f72f279c6597699b99912fd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTU4OjFFQTRENToxMjdGM0E6MTkwOTNCOjZBRkQ0QzYyIiwidmlzaXRvcl9pZCI6IjI2MDg0MTM3NTc5NTA3MjA5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c9a20ead19e810d1cc1a1e25bc15b20d54a51b5c95a8ce9b0d292ce964f062c7 |
| hovercard-subject-tag | issue:319531139 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/6801/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5823f08447d29348374e894dabc053aeff02e598d9bf159581960213fa007f32/PowerShell/PowerShell/issues/6801 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5823f08447d29348374e894dabc053aeff02e598d9bf159581960213fa007f32/PowerShell/PowerShell/issues/6801 |
| og:image:alt | #6778 tracks porting the Clear-RecycleBin cmdlet to PowerShell Core, and it would be helpful to support other recycle-bin/trash-related functionality too, notably the ability to move filesystem ite... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width