Package: textualize-see
Textualize SeeTextualize See is a command line tool to open files in the terminal.The job ofseeis run the appropriate command on your system to display a file in the terminal.
You can configure which command to run with a TOML file that maps a glob-style file pattern on to your chosen command.For instance, you could configureseeto open Python files withrich-cliand Rust files withbat.The configuration is flexible enough thatseecan run a different command depending on the directory. For example you might want to use a different command to open.htmlfiles (in reality, template files) in a Django project.While the default is toviewthe file, you can also request different actions, such as "edit", "format", "print" etc.InstallSeeis distributed as a Python package.
The easiest way to install it is probably withpipx.pipx textualize_seeThis will addseeto your path.UsageNoteYou will need to configureseebefore you use it.Callseewith a path to view that file in the terminal:see application.pyIf you add two arguments, then the first should be anaction, and the second should be a path.see edit application.pyThis will openapplication.pywith a command to edit the file.Any additional arguments added after the path are forwarded to the command.
In the following--pageris not an option forsee, so it will be forwarded to the command that opens the file.see application.py --pagerNote thatseewill run commands for configured paths only.
If there is no matching path thenseewill do nothing.
See below for configuration.ConfigureTextual reads its configuration from~/.see.toml(aTOMLfile).
This file should consist of several tables which specify the action (e.g. "view") and a glob style pattern to match against.The table should have arunkey which defines the command to run.
Therunvalue may contain$PATHor$ARGSwhich will be replaced with the path and forward arguments respectively.The following will match any files with the extension ".py":[[actions.view."*.py"]]run="rich $PATH $ARGS"If you were to run the followingseecommand:see application.py --pagerThenseewould pass the path torichalong with any options it doesn't recognize, such as--pager.rich application.py --pagerPriorityYou can optionally add apriorityinteger value, associated with a pattern.
If not provided,prioritywill default to 1.If more than one pattern matches the path, then the action with the highest priority will be used.
This can be used to add a fallback if there is no explicit match.
For example, we could add the following section tocatany files to the terminal that we haven't explicitly matched:[[actions.view."*"]]priority=0run="cat $PATH $ARGS"Why did I build this?I've always felt something like this should exist.
It is functionality that desktops take for granted, but the experience is not quite as transparent in the terminal.
There are alternatives (see below) but this is how I would want it work.
It is also cross-platform so I don't seem like a fish out of water on Windows.Why not just use ... ?Inevitably this will prompt the question "Why not just use TOOL?".
I don't want to talk you out of TOOL, but this is what I considered:open or xdg-openThere isopenon macOS, andxdg-openon Linux, which open files.
But these typically open desktop applications, and when I'm in the terminal I typically want to stay in the terminal.hash bangs?The hash bang#!is used toexecutethe file, while I just want to open it. It also requires that you can edit the file itself.shell aliasesYou could add an alias for each filetype you want to open, likemd-viewandmd-editetc.
Which is a perfectly reasonable use for alias, but it does require a command per filetype + action which is harder to commit to muscle memory.ZSH offersalias -swhich associates a file extension with a command.
For example if you have the aliasalias -s py=richthen you can enterfoo.pyto syntax a Python file.
I like this, but Ithinkit is only offered by thezshshell (may be wrong) and it is not cross platform.Why Python?It's Python because I am mainly a Python developer.
Tools like this do tend to be written a little closer to the metal.
Ifseebecomes popular and the interface stabilizes, then maybe I (or somebody else) will write it a compiled language.
Until then you might have to wait an additional few microseconds to run apps.SupportConsider this project alpha software for the time being.
It was written in under a day and hasn't been battle tests.
It has so far only been tested under MacOS, but the goal is to make it work across all the platforms.