Top Related Projects
Command line interface to the freedesktop.org trashcan.
Yet Another Dotfiles Manager
Command-line program to download videos from YouTube.com and other video sites
Magnificent app which corrects your previous console command.
📚 Collaborative cheatsheets for console commands
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Quick Overview
Trash-cli is a command-line interface (CLI) tool that moves files and folders to the trash/recycle bin instead of permanently deleting them. It provides a safer alternative to the rm
command, allowing users to recover accidentally deleted files. Trash-cli works cross-platform on macOS, Linux, and Windows.
Pros
- Safer file deletion with the ability to recover files from the trash
- Cross-platform compatibility (macOS, Linux, Windows)
- Simple and intuitive command-line interface
- Integrates well with existing shell workflows
Cons
- Requires installation and setup, unlike built-in
rm
command - May be slower than direct deletion for large files or numerous small files
- Limited functionality compared to some graphical file managers
- Doesn't provide advanced features like scheduled trash emptying
Getting Started
To install trash-cli, use npm:
npm install --global trash-cli
Basic usage:
# Move a file to the trash
trash file.txt
# Move multiple files to the trash
trash file1.txt file2.txt file3.txt
# Move a directory to the trash
trash my_directory/
# Empty the trash
trash-empty
# List items in the trash
trash-list
# Restore a file from the trash
trash-restore
Note: The trash-empty
, trash-list
, and trash-restore
commands are not available on Windows.
Competitor Comparisons
Command line interface to the freedesktop.org trashcan.
Pros of trash-cli (andreafrancia)
- More comprehensive feature set, including listing and emptying trash
- Better cross-platform support, including Windows
- More actively maintained with regular updates
Cons of trash-cli (andreafrancia)
- Larger codebase, potentially more complex to maintain
- Requires more dependencies
- Slightly slower execution due to additional features
Code Comparison
trash-cli (andreafrancia):
def trash(paths):
for path in paths:
if os.path.isdir(path):
trash_directory(path)
else:
trash_file(path)
trash-cli (sindresorhus):
const trash = async paths => {
paths = Array.isArray(paths) ? paths : [paths];
await Promise.all(paths.map(path => trashItem(path)));
};
The andreafrancia version handles directories and files separately, while the sindresorhus version uses a more streamlined approach. The andreafrancia implementation is in Python, whereas sindresorhus uses JavaScript, which may affect performance and compatibility on different systems.
Yet Another Dotfiles Manager
Pros of yadm
- Specialized for managing dotfiles across multiple systems
- Supports encryption of sensitive files
- Offers templating for system-specific configurations
Cons of yadm
- More complex setup and learning curve
- Limited to managing dotfiles and configurations
- Not designed for general file operations
Code Comparison
yadm:
yadm init
yadm add .vimrc
yadm commit -m "Add .vimrc"
yadm push
trash-cli:
trash file.txt
trash-list
trash-restore
trash-empty
Key Differences
- Purpose: yadm is focused on dotfile management, while trash-cli is a command-line interface for moving files to the trash
- Functionality: yadm offers version control and synchronization for configurations, whereas trash-cli provides a safer alternative to rm for file deletion
- Scope: yadm is tailored for system administrators and power users managing multiple machines, while trash-cli is useful for all users as a general file management tool
Use Cases
yadm is ideal for:
- Managing dotfiles across multiple systems
- Version controlling configuration files
- Maintaining consistent environments across machines
trash-cli is better suited for:
- Safely deleting files with the option to restore
- Managing the system trash from the command line
- Providing a more user-friendly alternative to rm
Command-line program to download videos from YouTube.com and other video sites
Pros of youtube-dl
- Versatile tool for downloading videos from various platforms, not limited to YouTube
- Supports extraction of audio-only content and playlist downloads
- Actively maintained with frequent updates and broad community support
Cons of youtube-dl
- More complex to use, with numerous options and flags
- Larger codebase and dependencies, potentially slower for simple operations
- May face legal challenges due to its primary function of downloading content
Code Comparison
youtube-dl:
from __future__ import unicode_literals
import youtube_dl
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
trash-cli:
const trash = require('trash');
(async () => {
await trash(['*.png', '!important.png']);
console.log('Files deleted');
})();
While youtube-dl focuses on downloading online content, trash-cli is designed for safe file deletion. The code snippets demonstrate their primary functions: youtube-dl for video downloading and trash-cli for moving files to the trash. youtube-dl's implementation is more complex due to its broader functionality, while trash-cli offers a simpler, more focused API for file management tasks.
Magnificent app which corrects your previous console command.
Pros of thefuck
- Automatically corrects mistyped console commands
- Supports a wide range of shells and applications
- Highly customizable with user-defined rules
Cons of thefuck
- May introduce unexpected behavior if not used carefully
- Requires Python installation and setup
- Learning curve to understand and customize rules
Code Comparison
thefuck:
@rule
def git_push_force(command):
return (command.script.startswith('git push')
and ' -f' not in command.script
and '--force' not in command.script)
trash-cli:
const fs = require('fs');
const path = require('path');
module.exports = (paths, options) => {
paths = Array.isArray(paths) ? paths : [paths];
Key Differences
- Purpose: thefuck focuses on correcting mistyped commands, while trash-cli is for safely deleting files
- Language: thefuck is written in Python, trash-cli in JavaScript
- Functionality: thefuck is more complex and versatile, trash-cli is more focused and straightforward
- Installation: thefuck requires Python setup, trash-cli is a simple npm package
- Usage: thefuck is used as a command prefix, trash-cli replaces the rm command
Both tools aim to improve the command-line experience, but they serve different purposes and have distinct implementation approaches.
📚 Collaborative cheatsheets for console commands
Pros of tldr
- Broader scope: Provides simplified documentation for many CLI commands, not just trash-related operations
- Community-driven: Large number of contributors and extensive language support
- Regularly updated with new commands and improvements
Cons of tldr
- Not a standalone tool: Requires installation and doesn't provide direct functionality
- Less focused: May not offer as detailed information for specific trash operations
Code comparison
tldr (example usage):
tldr rm
tldr trash-cli
trash-cli (example usage):
trash file.txt
trash-list
trash-restore
Summary
tldr is a comprehensive documentation project that simplifies man pages for various CLI commands, including trash-related operations. It offers a wide range of command explanations but doesn't provide direct functionality. On the other hand, trash-cli is a focused tool specifically designed for safe file deletion and management.
While tldr serves as an excellent reference for understanding commands, trash-cli provides a practical solution for users looking to safely delete files and manage their trash. The choice between the two depends on whether you need a broad reference guide or a specific tool for trash operations.
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Pros of ripgrep
- Significantly faster search performance, especially for large codebases
- Supports searching within compressed files and archives
- Respects .gitignore rules by default, improving search relevance
Cons of ripgrep
- More complex command-line options compared to trash-cli's simplicity
- Focused solely on searching, while trash-cli handles file deletion
- Requires more system resources due to its advanced features
Code Comparison
ripgrep example:
rg "pattern" --type-add 'web:*.{html,css,js}' --type web
trash-cli example:
trash file.txt
Key Differences
ripgrep is a powerful search tool designed for speed and advanced filtering, while trash-cli is a simple utility for safely moving files to the trash. Their purposes are quite different, with ripgrep excelling at code and text searching, and trash-cli focusing on file management.
ripgrep offers more features and flexibility for developers and power users, particularly those working with large codebases. trash-cli, on the other hand, provides a straightforward way to safely delete files across different operating systems.
The choice between these tools depends on the specific task at hand: use ripgrep for fast, advanced searching, and trash-cli for safe file deletion.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
trash-cli
Move files and folders to the trash
Works on macOS (10.12+), Linux, and Windows (8+).
In contrast to rm
which is dangerous and permanently deletes files, this only moves them to the trash, which is much safer and reversible. I would also recommend reading my guide on safeguarding rm
.
Accepts paths and glob patterns.
Install
npm install --global trash-cli
Usage
$ trash --help
Usage
$ trash <path|glob> [â¦]
Examples
$ trash unicorn.png rainbow.png
$ trash '*.png' '!unicorn.png'
Tip
Add alias rm=trash
to your .zshrc
/.bashrc
to reduce typing & safely trash files: $ rm unicorn.png
.
FAQ
Related
- trash - API for this package
- empty-trash-cli - Empty the trash
- del-cli - Delete files and folders
Top Related Projects
Command line interface to the freedesktop.org trashcan.
Yet Another Dotfiles Manager
Command-line program to download videos from YouTube.com and other video sites
Magnificent app which corrects your previous console command.
📚 Collaborative cheatsheets for console commands
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot