function trash --description "Move file or directory to the windows recycle bin." # Get function name set current_name $(status current-function) # Check if no arguments were provided if test -z $argv[1] echo -e "Usage: $current_name path/to/file" return 0 end # Move file to trash set file (wslpath -w $argv[1]) powershell.exe -Command "& {" \ " Add-Type -AssemblyName 'Microsoft.VisualBasic';" \ " Get-ChildItem -Path '$file' | ForEach-Object {" \ " if (\$_ -is [System.IO.DirectoryInfo]) {" \ " [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory(\$_.FullName, 'OnlyErrorDialogs', 'SendToRecycleBin')" \ " } else {" \ " [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile(\$_.FullName, 'OnlyErrorDialogs', 'SendToRecycleBin')" \ " }" \ " }" \ "}" end