Logo
Published on

How to Set csvlens as Your Default CSV Viewer on Ubuntu

Authors
  • avatar
    Name
    Jeremy Garrell
    Twitter

csvlens is a command-line CSV viewer, described in its own README as "like less but made for CSV." If you've already installed it with cargo install csvlens, you can make it the default app that opens whenever you double-click a .csv file on Ubuntu, in five steps: find the executable, create a .desktop entry, register it with xdg-mime, refresh the MIME database, and test it.

Windows and macOS have feature-rich spreadsheet apps built in. Linux often leaves you choosing between a clunky text editor and a full office suite just to glance at a CSV. csvlens fills that gap directly in the terminal, and once it's installed, wiring it up as your default viewer only takes a few steps.

Where is the csvlens executable after installing it with cargo?

Since you installed it with cargo install, the binary is most likely in your Cargo bin directory, usually ~/.cargo/bin/. Confirm the exact path:

which csvlens

This returns something like /home/yourusername/.cargo/bin/csvlens. Note the full path — you'll need it in the next step.

How do I create a desktop entry so Ubuntu knows how to launch csvlens?

A .desktop file tells your graphical environment how to launch an application. Create one at ~/.local/share/applications/csvlens.desktop:

nano ~/.local/share/applications/csvlens.desktop

Paste the following, replacing /home/yourusername/.cargo/bin/csvlens with the path from the previous step:

[Desktop Entry]
Name=CSVLens Viewer
Comment=View CSV files with csvlens in a terminal
Exec=gnome-terminal -- /bin/bash -c "/home/yourusername/.cargo/bin/csvlens %f; echo 'Press Enter to close'; read"
Icon=text-x-generic
Terminal=false
Type=Application
MimeType=text/csv;
Categories=Utility;TextEditor;

The Exec line does the actual work:

  • gnome-terminal -- opens the command in a new terminal window. Using a different terminal emulator (konsole, xfce4-terminal)? Swap it in here.
  • /bin/bash -c "..." runs a Bash command inside that terminal.
  • csvlens %f is the actual viewer; %f gets replaced with the path of whichever CSV file you clicked.
  • ; echo 'Press Enter to close'; read keeps the terminal open after csvlens exits, instead of closing immediately.

How do I set csvlens as the default app for CSV files?

Ubuntu uses xdg-mime to track default applications per file type. Check what's currently set for CSVs:

xdg-mime query default text/csv

Then point it at the .desktop file you just created:

xdg-mime default csvlens.desktop text/csv

Do I need to update the MIME database after this?

Refresh it so the change takes effect immediately, rather than waiting for the next login:

update-desktop-database ~/.local/share/applications/

How do I confirm it worked?

Navigate to a .csv file in your file manager and double-click it. A terminal window should open showing the file in csvlens. Press Enter (or any key) once you're done viewing to close it.

How does csvlens compare to less or a GUI spreadsheet app?

csvlens describes itself as "like less but made for CSV." That comparison holds up:

csvlenslessLibreOffice Calc
Built for CSV (columns, delimiters)YesNo — generic text pagerYes
Search/filterRegex search and filter, on rows and columnsPattern search only, no column structureAutoFilter and Find & Replace
Row limitNone documentedNone — streams the file, "does not have to read the entire input file before starting"1,048,576 rows per sheet
Needs a GUI/desktop environmentNoNoYes
Installcargo install csvlensTypically already installedFull office-suite install

If you just need to skim a CSV without column structure, less already does that. If you need charts, formulas, or heavy editing, Calc is the right tool. csvlens sits in between: fast, terminal-based, and CSV-aware without a GUI.

FAQ

The terminal opens and closes immediately — what's wrong? Double-check the Exec line in your csvlens.desktop file, especially the echo 'Press Enter to close'; read part. A small typo there is the most common cause.

csvlens doesn't open when I double-click a CSV file. What should I check? Confirm the path in Exec matches the output of which csvlens exactly, and that running csvlens your_file.csv directly in a terminal works. Also check MimeType=text/csv; for typos.

How do I revert to my previous default CSV app? Right-click a CSV file, choose "Open With Other Application," and pick your previous default — or set it directly with xdg-mime:

xdg-mime default libreoffice-calc.desktop text/csv

Is csvlens still actively maintained? Yes — the project has close to 4,000 GitHub stars, and its latest release (v0.15.1) shipped in January 2026.

Sources