From 7bc526012dcdf74b714a6cdbd0e923133cdeb4ae Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 4 Nov 2024 17:22:51 +0100 Subject: [PATCH] add trash-empty --- .config/fish/functions/trash-empty.fish | 18 ++++++++++++++++++ .config/fish/functions/trash.fish | 8 -------- Makefile | 1 + wsl.sh | 6 +++++- 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 .config/fish/functions/trash-empty.fish diff --git a/.config/fish/functions/trash-empty.fish b/.config/fish/functions/trash-empty.fish new file mode 100644 index 0000000..b75ed59 --- /dev/null +++ b/.config/fish/functions/trash-empty.fish @@ -0,0 +1,18 @@ +function trash --description "Empty 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" + return 0 + end + + # Empty trash + powershell.exe -Command "" \ + "\$bin = (New-Object -ComObject Shell.Application).NameSpace(10);" \ + "\$bin.items() | ForEach {" \ + " Write-Host 'Deleting:' \$_.Name;" \ + " Remove-Item \$_.Path -Recurse -Force;" \ + "}" +end diff --git a/.config/fish/functions/trash.fish b/.config/fish/functions/trash.fish index d7a38d0..79b113d 100644 --- a/.config/fish/functions/trash.fish +++ b/.config/fish/functions/trash.fish @@ -36,12 +36,4 @@ function trash --description "Move file or directory to the windows recycle bin. # Delete the WSL path rm -r "$element"; - - # Empty trash (move to another function!) - # powershell.exe -Command "" \ - # "\$bin = (New-Object -ComObject Shell.Application).NameSpace(10);" \ - # "\$bin.items() | ForEach {" \ - # " Write-Host 'Deleting:' \$_.Name;" \ - # " Remove-Item \$_.Path -Recurse -Force;" \ - # "}" end diff --git a/Makefile b/Makefile index 0df3910..c7468ab 100644 --- a/Makefile +++ b/Makefile @@ -179,6 +179,7 @@ sync-wsl: @$(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 + @$(WGET) $(REPO_SRC)/.config/fish/functions/trash-empty.fish -O $(HOME)/.config/fish/functions/trash-empty.fish @echo "Fish specific settings synced!" @echo diff --git a/wsl.sh b/wsl.sh index b657ae1..9702aea 100644 --- a/wsl.sh +++ b/wsl.sh @@ -83,7 +83,11 @@ function main { curl -s ${repo}/.config/fish/conf.d/abbr_wsl.fish >> "$HOME"/.config/fish/conf.d/abbr.fish curl -s ${repo}/.config/fish/conf.d/alias_wsl.fish >> "$HOME"/.config/fish/conf.d/alias.fish # Specific WSL functions - wget -q "${repo}"/.config/fish/functions/trash.fish -O "$HOME"/.config/fish/functions/trash.fish + functions=("trash" "trash-empty") + for function in "${functions[@]}" + do + wget -q "${repo}"/.config/fish/functions/"${function}".fish -O "$HOME"/.config/fish/functions/"${function}".fish + done # === OCaml ==