Add trash command for WSL
This commit is contained in:
parent
d782be8f90
commit
8898a93879
2 changed files with 24 additions and 0 deletions
23
.config/fish/functions/trash.fish
Normal file
23
.config/fish/functions/trash.fish
Normal 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
|
1
Makefile
1
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/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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue