feat: trash support for linux and mac (#165)

* wip: skeleton code for trash adapter

* refactor: split trash implementation for mac and linux

* fix: ensure we create the .Trash/$uid dir

* feat: code complete linux trash implementation

* doc: write up trash features

* feat: code complete mac trash implementation

* cleanup: remove previous, terrible, undocumented trash feature

* fix: always disabled trash

* feat: show original path of trashed files

* doc: add a note about calling actions directly

* fix: bugs in trash implementation

* fix: schedule_wrap in mac trash

* doc: fix typo and line wrapping

* fix: parsing of arguments to :Oil command

* doc: small documentation tweaks

* doc: fix awkward wording in the toggle_trash action

* fix: warning on Windows when delete_to_trash = true

* feat: :Oil --trash can open specific trash directories

* fix: show all trash files in device root

* fix: trash mtime should be sortable

* fix: shorten_path handles optional trailing slash

* refactor: overhaul the UI

* fix: keep trash original path vtext from stacking

* refactor: replace disable_changes with an error filter

* fix: shorten path names in home directory relative to root

* doc: small README format changes

* cleanup: remove unnecessary preserve_undo logic

* test: add a functional test for the freedesktop trash adapter

* test: more functional tests for trash

* fix: schedule a callback to avoid main loop error

* refactor: clean up mutator logic

* doc: some comments and type annotations
This commit is contained in:
Steven Arcangeli 2023-11-05 12:40:58 -08:00 committed by GitHub
parent d8f0d91b10
commit 6175bd6462
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 1580 additions and 229 deletions

View file

@ -8,6 +8,7 @@ CONTENTS *oil-content
3. Columns |oil-columns|
4. Actions |oil-actions|
5. Highlights |oil-highlights|
6. Trash |oil-trash|
--------------------------------------------------------------------------------
OPTIONS *oil-options*
@ -45,8 +46,6 @@ OPTIONS *oil-option
delete_to_trash = false,
-- Skip the confirmation popup for simple operations
skip_confirm_for_simple_edits = false,
-- Change this to customize the command used when deleting to trash
trash_command = "trash-put",
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first
prompt_save_on_select_new_entry = true,
-- Oil will automatically delete hidden buffers after this delay
@ -75,6 +74,7 @@ OPTIONS *oil-option
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
["g\\"] = "actions.toggle_trash",
},
-- Set to false to disable all of the above keymaps
use_default_keymaps = true,
@ -343,6 +343,8 @@ birthtime *column-birthtim
ACTIONS *oil-actions*
These are actions that can be used in the `keymaps` section of config options.
You can also call them directly with
`require("oil.actions").action_name.callback()`
cd *actions.cd*
:cd to the current oil directory
@ -408,11 +410,14 @@ tcd *actions.tc
toggle_hidden *actions.toggle_hidden*
Toggle hidden files and directories
toggle_trash *actions.toggle_trash*
Jump to and from the trash for the current directory
--------------------------------------------------------------------------------
HIGHLIGHTS *oil-highlights*
OilDir *hl-OilDir*
Directories in an oil buffer
Directory names in an oil buffer
OilDirIcon *hl-OilDirIcon*
Icon for directories
@ -423,6 +428,9 @@ OilSocket *hl-OilSocke
OilLink *hl-OilLink*
Soft links in an oil buffer
OilLinkTarget *hl-OilLinkTarget*
The target of a soft link
OilFile *hl-OilFile*
Normal files in an oil buffer
@ -441,5 +449,45 @@ OilCopy *hl-OilCop
OilChange *hl-OilChange*
Change action in the oil preview window
OilRestore *hl-OilRestore*
Restore (from the trash) action in the oil preview window
OilPurge *hl-OilPurge*
Purge (Permanently delete a file from trash) action in the oil preview
window
OilTrash *hl-OilTrash*
Trash (delete a file to trash) action in the oil preview window
OilTrashSourcePath *hl-OilTrashSourcePath*
Virtual text that shows the original path of file in the trash
--------------------------------------------------------------------------------
TRASH *oil-trash*
Oil has built-in support for using the system trash. When
`delete_to_trash = true`, any deleted files will be sent to the trash instead
of being permanently deleted. You can browse the trash for a directory using
the `toggle_trash` action (bound to `g\` by default). You can view all files
in the trash with `:Oil --trash /`.
To restore files, simply delete them from the trash and put them in the desired
destination, the same as any other file operation. If you delete files from the
trash they will be permanently deleted (purged).
Linux:
Oil supports the FreeDesktop trash specification.
https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html
All features should work.
Mac:
Oil has limited support for MacOS due to the proprietary nature of the
implementation. The trash bin can only be viewed as a single dir
(instead of being able to see files that were trashed from a directory).
Windows:
Oil does not yet support the Windows trash. PRs are welcome!
================================================================================
vim:tw=80:ts=2:ft=help:norl:syntax=help: