Skip to content

Instantly share code, notes, and snippets.

@natsumerinchan
Last active February 25, 2023 16:34
Show Gist options
  • Save natsumerinchan/5d8584968a13c3589a60152b52f02274 to your computer and use it in GitHub Desktop.
Save natsumerinchan/5d8584968a13c3589a60152b52f02274 to your computer and use it in GitHub Desktop.
trash-cli helper
#!/usr/bin/bash
if [ ! "$1" ] || [ "$1" == "help" ]; then
if [ "$2" == "" ]; then
echo "Get command help: trash-cli help <put/empty/list/restore/rm>"
echo "help 获取帮助"
echo "put 把文件或目录移动到回收站"
echo "empty 清空回收站"
echo "list 列出回收站文件"
echo "restore 恢复回收站文件"
echo "rm 删除回收站文件"
elif [ "$2" == "put" ]; then
echo "put 把文件或目录移动到回收站"
echo "usage: trash-cli put <file/folder directory>"
elif [ "$2" == "empty" ]; then
echo "empty 清空回收站"
echo "usage: trash-cli empty"
elif [ "$2" == "list" ]; then
echo "list 列出回收站文件"
echo "usage: trash-cli list"
elif [ "$2" == "restore" ]; then
echo "restore 恢复回收站文件"
echo "usage: trash-cli restore"
elif [ "$2" == "rm" ]; then
echo "rm 删除回收站文件"
echo "只删除符合某种格式的文件:"
echo "Such as: trash-cli rm \*.o"
elif [ "$3" != "" ]; then
echo "trash-cli: No such options."
else
echo "trash-cli: No such options."
fi
elif [ "$1" == "put" ]; then
if [ "$2" == "" ]; then
echo "put 把文件或目录移动到回收站"
echo "usage: trash-cli put <file/folder directory>"
else
trash-put $2
fi
elif [ "$1" == "empty" ]; then
trash-empty
elif [ "$1" == "list" ]; then
trash-list
elif [ "$1" == "restore" ]; then
trash-restore
elif [ "$1" == "rm" ]; then
if [ "$2" == "" ]; then
echo "rm 删除回收站文件"
echo "只删除符合某种格式的文件:"
echo "Such as: trash-cli rm \*.o"
else
trash-rm $2
fi
else
echo "trash-cli: No such options."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment