Add trash command for WSL

This commit is contained in:
Mylloon 2024-01-01 18:07:07 +01:00
parent d782be8f90
commit 8898a93879
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,23 @@
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 "$argv[1]"
powershell.exe -Command "& {" \
" Add-Type -AssemblyName 'Microsoft.VisualBasic';" \
" Get-ChildItem -Path $file | ForEach-Object {" \
" if (\$_.GetType() -eq [System.IO.DirectoryInfo]) {" \
" [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory(\$_.FullName, 'OnlyErrorDialogs', 'SendToRecycleBin')" \
" } else {" \
" [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile(\$_.FullName, 'OnlyErrorDialogs', 'SendToRecycleBin')" \
" }" \
" }" \
"}"
end

View file

@ -145,6 +145,7 @@ sync-wsl:
@$(CURL) $(REPO_SRC)/.config/fish/config_wsl.fish >> $(HOME)/.config/fish/config.fish @$(CURL) $(REPO_SRC)/.config/fish/config_wsl.fish >> $(HOME)/.config/fish/config.fish
@$(CURL) $(REPO_SRC)/.config/fish/conf.d/abbr_wsl.fish >> $(HOME)/.config/fish/conf.d/abbr.fish @$(CURL) $(REPO_SRC)/.config/fish/conf.d/abbr_wsl.fish >> $(HOME)/.config/fish/conf.d/abbr.fish
@$(CURL) $(REPO_SRC)/.config/fish/conf.d/alias_wsl.fish >> $(HOME)/.config/fish/conf.d/alias.fish @$(CURL) $(REPO_SRC)/.config/fish/conf.d/alias_wsl.fish >> $(HOME)/.config/fish/conf.d/alias.fish
@$(WGET) $(REPO_SRC)/.config/fish/functions/trash.fish -O $(HOME)/.config/fish/functions/trash.fish
@echo "Fish specific settings synced!" @echo "Fish specific settings synced!"
@echo @echo