A lightweight Bash script to mount and unmount USB drives and automatically open Ranger at the mount point.
Designed for minimalist Linux environments and keyboard-driven workflows such as qtile, i3, sway, and bspwm.
In many minimalist setups, mounting a USB drive usually means:
- opening a terminal
- running mount commands manually
- navigating to the mount point
- dealing with permissions or root access
This project removes that friction.
With a single command or keybinding, your USB device is mounted safely and opened directly in Ranger — no root, no mouse, no hassle.
- 🔌 Safe mount and unmount using
udisksctl - 📂 Automatically opens Ranger at the mount point
- 🔢 Supports multiple USB devices using numeric indexes
- ⌨️ Perfect for window manager keybindings
- 🔧 Configurable terminal and file manager
- 🚫 No root permissions required
- 🧠 Simple, readable, and hackable Bash script
The following tools must be installed:
bashudisks2lsblk(fromutil-linux)rangeralacritty(or any terminal emulator)
sudo pacman -S udisks2 util-linux ranger alacritty
### Installation
git clone https://github.com/YOUR_USERNAME/ranger-usb-manager.git
cd ranger-usb-manager
chmod +x usb-manager.sh
cp usb-manager.sh ~/.local/bin/
###Usage
##Mount a USB device
usb-manager.sh mount 1
###Unmount a USB device
usb-manager.sh unmount 1
USB devices are indexed starting from 1, based on the order
reported by lsblk.
###Configuration
You can override the terminal emulator or file manager
using environment variables:
TERMINAL=kitty FILEMANAGER=lf usb-manager.sh mount 1