DEV Community

chovy
chovy

Posted on Originally published at dev.profullstack.com

DiskPush 0.11: view, edit and open files without leaving the terminal browser

DiskPush 0.9, 0.10 and 0.11, all out today, teach the terminal browser to open files. Press v on any file in diskpush tui and it opens under the two panes, rendered. Press e and it opens in your editor. Press x and it opens with whatever your system opens it with.

╭─  ▪ Local  ──────────── /home/me/project ─┬─  ▪ prod  ──────────── /srv/app ─╮
│ ↑ ..                                      │ ↑ ..                             │
│ ▸ src                                     │   bundle.js              1.5M    │
│   README.md                        4.1K   │                                  │
╰─  2 items  ·  4.1K  ·  name▲  ────────────┴─  1 item  ·  1.5M  ·  name▲  ───╯
╭─  README.md  ───────────────────────────────────── /home/me/project/README.md ─╮
│ DiskPush                                                                   █ │
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │
│ Push files fast. Sync only what changed.                                   │ │
╰─  lines 1–16 of 180  ·  markdown  ·  6.6K  ──────────────────────────────────╯
 tab pane  ↑↓ file  pgdn pgup page  g G top end  e edit  x open…  esc close  q quit
Enter fullscreen mode Exit fullscreen mode

v: a preview, not a detour

The panes keep their share of the screen and the document takes the rest. The arrows stay with the panes, so with a file open, and walk from one file to the next and the viewer follows. pgdn and pgup page the document, g and G jump to its ends, and the mouse wheel scrolls it. on a file opens it too, a click on another file switches to it, and esc closes it.

It works the same on a remote pane. The file is read over the SFTP session the listing came from, so there is nothing to download first.

What it shows:

  • Markdown is rendered by readm3, our terminal markdown reader, used here as a library. Headings, lists, fenced code, quotes, links and GitHub alerts all come out the way readm3 draws them.
  • A file with no extension, like README or NOTES, is checked by our text type detector and rendered as markdown when it reads as markdown.
  • Text shows as numbered lines with tabs widened.
  • Images are drawn in the terminal. A PNG, JPEG, GIF, WebP or BMP is handed to the terminal over the iTerm2 inline-image protocol or the kitty graphics protocol, so WezTerm, kitty, Ghostty, iTerm2 and Konsole all draw it, an icon at its own size and a photo shrunk to fit. It works inside tmux as well: the browser turns on passthrough for its own pane, so there is no config to edit.
  • Binaries show as a hex dump of their head, with a line saying what would open them.

Only the first megabyte of a document is ever read, and up to eight of an image. A file browser cursor lands on backups and videos as often as on documents, and the footer says first 1.0M of 40G when that is what you are looking at.

e: your editor, in a tmux window

e opens the file under the cursor in $VISUAL, then $EDITOR, then whichever of vim, nvim, nano or vi is installed. Under tmux the editor gets a window of its own, named after the file, and the browser keeps running beside it. Without tmux the browser hands the terminal over the way vim's :sh does, and comes back when you quit the editor, with every pane where it was and the open file re-read.

A remote file is edited on the server, over ssh -t, with the editor the server has. Nothing is downloaded and nothing has to be uploaded back. The file the editor saves is the file.

x: whatever opens this

x hands the file to the desktop opener when there is a desktop, exactly as a double click would. On a server there is no desktop, so a video or a song goes to a player (mpv, ffplay, vlc) and an image to a viewer that draws in the terminal (chafa, timg, viu), each in its own tmux window. When nothing fits, the message names what to install.

The bytes outrank the name. A text file called code.ts is TypeScript, not an MPEG transport stream, and it is never sent to a player.

Get it

diskpush update
Enter fullscreen mode Exit fullscreen mode

or, fresh:

curl -fsSL https://diskpush.com/install.sh | sh
Enter fullscreen mode Exit fullscreen mode

Release notes and binaries: https://github.com/profullstack/diskpush/releases/tag/v0.11.0

Top comments (0)