e is a small Bash utility that opens the most recently modified text file in the current directory.
It scans only the current folder, filters files by MIME type (text/*), sorts by newest first, and opens the selected file using the first available editor in this order: nvim, vim, nano, vi, less. If the file is not writable, it opens with sudo.
- Linux with Bash
- One editor installed:
nvim,vim,nano,vi, orless - Common command-line tools:
find,file,sort,grep,sudo
This is the default setup for this project. It keeps the repository in ~/repos/e, makes the script executable, and creates ~/.local/bin/e only when it does not already exist:
mkdir -p ~/repos ~/.local/bin
if [ -d ~/repos/e/.git ]; then
git -C ~/repos/e pull --ff-only
else
git clone https://github.com/llagerlof/e.git ~/repos/e
fi
chmod +x ~/repos/e/e
if [ ! -e ~/.local/bin/e ]; then
ln -s ~/repos/e/e ~/.local/bin/e
fiIf ~/.local/bin is not already on your PATH, add it in your shell profile before using e from anywhere.
If you do not want a local clone, download the script directly:
mkdir -p ~/.local/bin
curl -fsSL https://raw.githubusercontent.com/llagerlof/e/main/e -o ~/.local/bin/e
chmod +x ~/.local/bin/eTo make e available system-wide, keep the repository in a normal user's home directory and link it into /usr/local/bin:
mkdir -p ~/repos
if [ -d ~/repos/e/.git ]; then
git -C ~/repos/e pull --ff-only
else
git clone https://github.com/llagerlof/e.git ~/repos/e
fi
chmod +x ~/repos/e/e
if [ ! -e /usr/local/bin/e ]; then
sudo ln -s "$HOME/repos/e/e" /usr/local/bin/e
fiTo install the script directly into /usr/local/bin:
tmpfile="$(mktemp)"
curl -fsSL https://raw.githubusercontent.com/llagerlof/e/main/e -o "$tmpfile"
chmod +x "$tmpfile"
sudo mv "$tmpfile" /usr/local/bin/ee [-h] [number]-h: include hidden filesnumber: 1-based order of the newest text file to open (1means newest)
Open the newest text file:
eOpen the second newest text file:
e 2Include hidden files and open the newest match:
e -h 1- Searches only the current directory (
maxdepth=1), not subdirectories. - If no text files are found, the script exits with a message.