A lightweight, terminal-based file manager built in C++17 that provides core file system operations similar to Linux command-line tools.
MiniFileExplorer is a command-line file management tool that allows users to navigate, create, delete, search, and manipulate files and directories through an interactive terminal interface. It's designed to be simple, efficient, and user-friendly.
- ✅ Directory Navigation: Change directories with
cd, support for relative/absolute paths and~for home directory - ✅ File Listing: List directory contents with detailed information (name, type, size, modification time)
- ✅ File Creation: Create empty files with
touch - ✅ Directory Creation: Create directories with
mkdir, recursive creation withmkdir -p - ✅ File Deletion: Delete files with confirmation prompt using
rm, recursive deletion withrm -r - ✅ Directory Deletion: Delete empty directories with
rmdir - ✅ File Information: Get detailed file/directory metadata with
stat
- 🔍 Recursive Search: Case-insensitive file/folder name search across subdirectories with
search - 📋 File Operations: Copy and move files/folders; recursive directory copy with
cp -r; hard/symlink creation withln - 📊 Directory Analysis: Calculate total directory size with automatic unit conversion (B/KB/MB)
- 🔄 Sorting Options: Sort listings by size (
ls -s) or modification time (ls -t); sort file contents withsort - 👁️ File Content Viewing: Display file contents with
cat, view first/last lines withhead/tail - 📝 File Statistics: Count lines, words, and bytes with
wc; filter duplicate lines withuniq - 🌲 Directory Tree: Visualize directory structure with
tree - 🔎 Content Search: Search inside file contents with
grep(line numbers, case-insensitive) - 🗂️ Multi-filter Find: Find files and directories by name/type/extension/size with
find(supports glob patterns with-name *.cpp) - 🔐 Permission Management: View and change Unix file permissions with
ls -landchmod - 📄 File Diff: Compare two files line by line with color-coded output using
diff
- 🎯 Interactive Command Prompt: Compact shell-style prompt showing current directory
- 📖 Help System: Built-in help command listing all available commands
- ✨ Error Handling: Comprehensive error messages for invalid operations
- 🔒 Safety Features: Confirmation prompts for destructive operations
- 🎨 Colored Output: ANSI-colored
lsandtreelistings — directories in blue, executables in green, symlinks in cyan, hidden files in gray, keyword matches in red - ⌨️ Command History: Up/Down arrow keys to navigate previous commands;
historycommand to list them (implemented viatermios, no external dependencies) - 🔡 Tab Completion: Press Tab to auto-complete command names and file paths; shows all matches on double-Tab
- 🌐 Glob Expansion: Use
*and?wildcards in any command (ls *.txt,rm *.log) - 🏷️ Command Aliases: Define session-scoped shortcuts with
alias/unalias
- C++ Compiler with C++17 support:
- GCC 7.0 or higher
- Clang 5.0 or higher
- MSVC 2017 or higher
- CMake version 3.10 or higher
- Standard C++ Filesystem Library (included in C++17)
- POSIX
termiosfor arrow-key history (available on Linux/macOS by default)
# Clone or navigate to the project directory
cd MiniFileExplorer
# Create build directory and compile
mkdir -p build
cd build
cmake ..
make
# Run the application
./MiniFileExplorercmake -B build -S .
cmake --build build
./build/MiniFileExplorerIf you encounter filesystem library errors with older compilers, uncomment line 17 in CMakeLists.txt:
target_link_libraries(MiniFileExplorer stdc++fs)# Start in current working directory
./MiniFileExplorer
# Start in a specific directory
./MiniFileExplorer /path/to/directoryOnce started, you'll see a shell-style prompt with the current directory:
Welcome to MiniFileExplorer!
Use ↑↓ arrow keys to navigate history. Type 'help' for all commands.
[/home/user/documents] $
Use the Up/Down arrow keys to cycle through previously entered commands.
| Command | Description | Example |
|---|---|---|
cd [path] |
Change directory | cd documents, cd .., cd ~ |
cd |
Switch to home directory | cd |
ls |
List directory contents | ls |
ls -a |
Include hidden files (dotfiles) | ls -a |
ls -l |
Long format with permissions | ls -l |
ls -s |
Sort by size (descending) | ls -s |
ls -t |
Sort by modification time | ls -t |
pwd |
Print current working directory | pwd |
tree [dir] |
Display directory as a tree | tree src |
tree [dir] -a |
Include hidden files in tree | tree -a |
tree [dir] -L N |
Limit tree depth to N levels | tree -L 2 |
| Command | Description | Example |
|---|---|---|
touch [filename] |
Create an empty file | touch note.txt |
mkdir [foldername] |
Create a directory | mkdir archive |
mkdir -p [path] |
Create directories recursively | mkdir -p a/b/c |
rm [filename] |
Delete a file (with confirmation) | rm old.txt |
rm -r [directory] |
Recursively delete a directory | rm -r tmp/ |
rmdir [foldername] |
Delete an empty directory | rmdir temp |
stat [name] |
Show detailed file/directory info | stat note.txt |
chmod [mode] [file] |
Change file permissions | chmod 755 script.sh |
ln [target] [link] |
Create a hard link | ln file.txt hard.txt |
ln -s [target] [link] |
Create a symbolic link | ln -s /etc/hosts hosts |
| Command | Description | Example |
|---|---|---|
cat [file] |
Display full file contents | cat notes.txt |
cat [file] -n |
Display with line numbers | cat notes.txt -n |
head [file] |
Show first 10 lines | head notes.txt |
head [file] -n N |
Show first N lines | head notes.txt -n 5 |
tail [file] |
Show last 10 lines | tail notes.txt |
tail [file] -n N |
Show last N lines | tail notes.txt -n 20 |
wc [file] |
Count lines, words, and bytes | wc notes.txt |
sort [file] |
Sort file lines alphabetically | sort names.txt |
sort [file] -r |
Sort in reverse order | sort names.txt -r |
sort [file] -n |
Sort numerically | sort sizes.txt -n |
uniq [file] |
Remove adjacent duplicate lines | uniq sorted.txt |
uniq [file] -c |
Show duplicate count prefix | uniq sorted.txt -c |
grep [kw] [file] |
Search file contents for keyword | grep TODO main.cpp |
grep [kw] [file] -n |
Show matching line numbers | grep TODO main.cpp -n |
grep [kw] [file] -i |
Case-insensitive match | grep error log.txt -i |
diff [file1] [file2] |
Compare two files line by line | diff old.txt new.txt |
| Command | Description | Example |
|---|---|---|
search [keyword] |
Search file/folder names recursively | search .txt |
find |
Find with filters (combinable) | see below |
find [dir] -name [pat] |
Match filename substring | find src -name util |
find [dir] -type f|d |
Filter by file or directory | find . -type f |
find [dir] -ext [.xxx] |
Filter by file extension | find src -ext .cpp |
find [dir] -size +N|-N |
Filter by size in KB | find . -size +100 |
| Command | Description | Example |
|---|---|---|
cp [source] [target] |
Copy a file | cp file.txt backup/ |
cp -r [dir] [target] |
Recursively copy a directory | cp -r src/ src_backup/ |
mv [source] [target] |
Move/rename file or folder | mv old.txt new.txt |
du [foldername] |
Calculate directory size | du documents |
| Command | Description | Example |
|---|---|---|
alias [name=value] |
Define a command alias | alias ll=ls |
alias [name] |
Show a specific alias | alias ll |
alias |
List all defined aliases | alias |
unalias [name] |
Remove an alias | unalias ll |
| Command | Description |
|---|---|
help |
Show all available commands |
history |
Show command history |
clear |
Clear the terminal screen |
exit |
Exit MiniFileExplorer |
[/home/user] $ cd documents
[/home/user/documents] $ touch notes.txt
Created file: notes.txt
[/home/user/documents] $ mkdir -p archive/2024
Created directory: archive/2024
[/home/user/documents] $ ls
Name Type Size(B) Modify Time
notes.txt File 0 2024-05-20 14:30:00
archive/ Dir - 2024-05-20 14:30:15
[/home/user/documents] $ ls -l
Permissions Type Size(B) Modify Time Name
--------------------------------------------------------------------------------
rw-r--r-- File 1024 2024-05-20 15:10:23 notes.txt
rwxr-xr-x Dir - 2024-05-20 14:30:15 archive/
[/home/user/documents] $ chmod 755 notes.txt
Permissions changed: notes.txt -> 755 (rwxr-xr-x)
[/home/user/documents] $ tree archive -L 2
archive/
├── 2024/
│ ├── jan.txt
│ └── feb.txt
└── readme.md
[/home/user/documents] $ cat notes.txt -n
1 Hello, world!
2 This is a TODO item.
[/home/user/documents] $ grep TODO notes.txt -n -i
2: This is a TODO item.
1 match(es) found.
[/home/user] $ find documents -ext .txt -size -10
/home/user/documents/notes.txt (File)
/home/user/documents/archive/2024/jan.txt (File)
2 result(s) found.
[/home/user] $ find documents -type d
/home/user/documents/archive (Dir)
/home/user/documents/archive/2024 (Dir)
2 result(s) found.
[/home/user] $ history
1 ls -l
2 cd documents
3 grep TODO notes.txt -n
4 chmod 755 script.sh
Use ↑/↓ arrow keys to recall previous commands directly at the prompt.
[/home/user/documents] $ diff v1.txt v2.txt
--- v1.txt
+++ v2.txt
Hello, world!
- This is the old line.
+ This is the new line.
Goodbye.
[/home/user/documents] $ alias ll=ls -l
Alias set: ll='ls'
[/home/user/documents] $ ll
Permissions Type Size(B) ...
[/home/user/documents] $ ls *.txt
notes.txt File ...
archive.txt File ...
[/home/user/documents] $ rm *.log
Are you sure to delete error.log? (y/n) y
Deleted: error.log
[/home/user/documents] $ ca<TAB>
cat cat cd
[/home/user/documents] $ cat no<TAB>
[/home/user/documents] $ cat notes.txt
[/home/user/documents] $ rm old.txt
Are you sure to delete old.txt? (y/n) y
Deleted: old.txt
[/home/user/documents] $ rm -r tmp/
Are you sure to recursively delete directory 'tmp/' and all its contents? (y/n) y
Deleted: tmp/
MiniFileExplorer/
├── CMakeLists.txt # Build configuration
├── README.md # This file
├── src/ # Source code directory
│ ├── main.cpp # Application entry point
│ ├── App.h/cpp # Main application loop + line editor
│ ├── Command.h/cpp # Command registry system
│ ├── Commands.h/cpp # Built-in command implementations
│ ├── CommandParser.h/cpp # Input tokenization
│ ├── FileSystemContext.h # Application state (incl. command history)
│ ├── FileInfo.h # File metadata structure
│ └── FsUtil.h/cpp # File system utilities
└── build/ # Build directory (generated)
The project follows a modular architecture with clear separation of concerns:
- Application Layer (
App.h/cpp): Main event loop,termios-based line editor with history navigation - Command System (
Command.h/cpp,Commands.h/cpp): Command registration and execution - Parser Layer (
CommandParser.h/cpp): Input tokenization - File System Layer (
FsUtil.h/cpp): Low-level file operations - Data Structures (
FileSystemContext.h,FileInfo.h): State management including command history
- Command Pattern: Commands are encapsulated as handler functions
- Registry Pattern: Centralized command lookup and management
- Namespace Organization: File utilities grouped in
fsutilnamespace
The application provides clear error messages for common issues:
Invalid directory: [path]- Directory doesn't existNot a directory: [path]- Path points to a fileFile already exists: [name]- Cannot create duplicate fileDirectory not empty: [name]- Cannot delete non-empty directoryTarget not found: [name]- File/directory doesn't existSource not found- Source path doesn't existFile exists in target: Overwrite? (y/n)- Overwrite confirmationInvalid mode: [mode]-chmodreceived non-octal input
To add a new command:
- Add the command registration in
src/Commands.cpp:
registry.registerCommand(
"mycommand",
"Description of my command",
[](const vector<string>& args, FileSystemContext& ctx) {
// Implementation here
}
);- Implement file system operations in
src/FsUtil.cppif needed.
# Debug build
cmake -DCMAKE_BUILD_TYPE=Debug -B build .
cmake --build build
# Release build
cmake -DCMAKE_BUILD_TYPE=Release -B build .
cmake --build buildThis project is developed as an educational file manager demonstration.
This is an educational project. Suggestions and improvements are welcome!
Potential features for future versions:
- Configuration file support (
.miniferc) — persist aliases and settings across sessions zip/unzip— archive support- Pipe operator (
|) — chain commands likecat file.txt | grep TODO - Multi-column
lsoutput - Use Rust to rewrite this project
Built using:
- C++17 Standard Library
<filesystem>library for file operations<termios.h>for terminal raw mode (arrow-key history)- CMake for build configuration
Note: This is a terminal-based application. Ensure your terminal supports UTF-8 encoding for best display results.