diff --git a/.config/fish/functions/trash.fish b/.config/fish/functions/trash.fish new file mode 100644 index 0000000..f54d5cd --- /dev/null +++ b/.config/fish/functions/trash.fish @@ -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 diff --git a/Makefile b/Makefile index 7c4d8bc..e305cff 100644 --- a/Makefile +++ b/Makefile @@ -145,6 +145,7 @@ sync-wsl: @$(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/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