Show HN: Fisherman – Plugin manager and CLI toolkit for fish shell
So, to answer the most important question, WHY do I want this thing?<p>Long wall of text ahead, but I promise this covers a lot.<p>---<p>If you are only using fish, you are missing out the ability to effectively share plugins, prompts, configs, missing completions, documentation for external utilities, plain old scripts or bundle of scripts.<p>If you are using Oh My Fish (OMF) &#x2F; Wahoo or Tacklebox, you may be already doing some of the above, just very poorly.<p>---<p><i></i><i>So</i><i></i>, I want to create shell scripts, snippets or let&#x27;s call them utilities that follow the [UNIX guidelines](<a href="http:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;basedefs&#x2F;V1_chap12.html" rel="nofollow">http:&#x2F;&#x2F;pubs.opengroup.org&#x2F;onlinepubs&#x2F;9699919799&#x2F;basedefs&#x2F;V1_...</a>) for option parsing, fish auto-completion out of the box, with bundled documentation using the traditional `man(1)` pages like a boss, and I want my scripts to come not only in the form of `.fish` files, but I want to ship them bundled with scripts in other languages too sometimes, maybe Awk or Perl, or if you are cool, Python. Then I want to commit that to a GitHub repository, or as a Gist, or to BitBucket, GitLabs or my own server if I want.<p>---<p>Fisherman makes this process very easy and it also gives me access to an external [&quot;index&quot;](<a href="https:&#x2F;&#x2F;github.com&#x2F;fisherman&#x2F;fisher-index" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fisherman&#x2F;fisher-index</a>) to where I can publish these utilities, let&#x27;s better call them now <i></i>plugins<i></i> so that others can discover my stuff without having to know the URL in advance.<p>Fisherman is not like, say `brew` where you typically share one or more binaries, that&#x27;s a true package manager indeed.<p>---<p>Fisherman, however, is about sharing snippets, prompts, configurations, initialization scripts, like I said above, that kind of stuff. In the Fisherman jargon, I am rolling all that into a bun and calling it &quot;plugin&quot;.<p>---<p>To Fisherman they are all the same, they <i></i>should<i></i> be, and if that&#x27;s not the case your &quot;framework&quot;, &quot;manager&quot;, whatever, is not doing you any service.<p>---<p>There are several different setups that Fisherman understands and can process. Why? Because there are already existing snippets and plugins with their own idiosyncrasies. The same ones I mentioned above. Also people creating stuff in fish and releasing it without a particular &quot;framework&quot; in mind.<p>---<p>Fisherman recognizes packages from all of those dimensions and lets you install them and use them as you wish. Without strange restrictions that these other &quot;frameworks&quot; often pose on you, like strange name conventions or strict URL forms. It _will even__ try to guess the URL and correct your mistakes sometimes.<p>---<p>You can also &quot;install&quot; stuff locally and it will symlink a directory to Fisherman&#x27;s configuration directory so that you can develop, test and iterate :repeat: fast and without having to do anything but `(1)` creating a directory and `(2)` typing `fisher install .` or `fisher install &lt;my_path&gt;`. You can commit your changes to a Git repo and that will not affect the process. It just works™.<p>---<p>But also you get a builtin (obviously it&#x27;s builtin) <i></i>cache system<i></i> to let you install stuff while you are offline (assuming you already downloaded the _stuff_ first) and that segues into Fisherman&#x27;s simplest, but IMO best feature, the <i></i><i>flat tree</i><i></i> :evergreen_tree:.<p>Here is the thing, Fisherman is as fast as <i></i><i>no</i>* Fisherman.<p>The [initialization script](<a href="https:&#x2F;&#x2F;github.com&#x2F;fisherman&#x2F;fisherman&#x2F;blob&#x2F;master&#x2F;config.fish" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fisherman&#x2F;fisherman&#x2F;blob&#x2F;master&#x2F;config.fi...</a>) basically declares a few variables and evaluates only config files that <i></i>you<i></i> allow Fisherman to evaluate. Period.<p>---<p>On the other hand, legacy OMF and modern OMF, Wahoo and Tacklebox mutate a variable to add &#x2F; remove paths as you install &#x2F; uninstall plugins. This is slower than loading all your functions into a single directory and telling fish to load only that.<p>---<p>But wait, you say, a flat tree means every function will be public and there ought to be name collisions and what not. Well, that&#x27;s how it has always been. If you were under the impression there was such thing as private function scope, I am sorry, there isn&#x27;t.<p>* <a href="http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;25088699&#x2F;make-fish-functions-private" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;25088699&#x2F;make-fish-functi...</a><p>* <a href="https:&#x2F;&#x2F;github.com&#x2F;fish-shell&#x2F;fish-shell&#x2F;issues&#x2F;1799" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fish-shell&#x2F;fish-shell&#x2F;issues&#x2F;1799</a><p>---<p>This is a &quot;deficiency&quot; (or feature maybe?) of the language and there is no way around the implications of this. You create a function and then remove it from the scope, but that does not change the fact _that function_ will replace any other function with the same name.<p>---<p>Now, you can always add prefixes to your functions or use underscores at the beginning of the function name like most folks do anyway. So, by using an underscore you express your intention to mark this function as private, but it&#x27;s just as &quot;public&quot; as any other.<p>Well, if fish has no private function scope, then it makes sense to use a flat tree for speed.<p>---<p>In the case of OMF and admitedly Wahoo too, things are even worse :sweat_smile:  because these two boys use fish [_event handlers_](<a href="http:&#x2F;&#x2F;fishshell.com&#x2F;docs&#x2F;current&#x2F;commands.html#emit" rel="nofollow">http:&#x2F;&#x2F;fishshell.com&#x2F;docs&#x2F;current&#x2F;commands.html#emit</a>) during their initialization process, and since fish <i></i><i>does not</i>* automatically load files with events (there is just no convention for this ATM), they need to source <i></i>every single<i></i> `.fish` file inside <i></i>each<i></i> plugin&#x27;s directory and inmediately `emit EVENT_NAME` adding yet another step in the process.<p>---<p>Events are great for communicating between different components &#x2F; areas in a complex application, and I originally thought of using them in Fisherman despite the (arguably small) performance overhead, but desisted when I realized whatever happens inside an event handler, does not leak. They are essentially black holes and useless if you want to parse any output generated inside the handler &#x2F; function.<p>---<p>One of Fisherman features is UNIX stinkiness. I don&#x27;t think the UNIX philosophy (whatever that was) is a creed unbreakble doctrine, but I like to write my functions and utilities so that they can be plug &#x2F; plumb into one another easily. That&#x27;s why everything is a &quot;stream&quot; and all the commands Fisherman ships with read the standard input and do what you would expect if you are already familiar in how UNIX typically works. This is one of the principles I based while writing this, so it&#x27;s everywhere. It&#x27;s also [here](<a href="https:&#x2F;&#x2F;github.com&#x2F;bucaran&#x2F;getopts" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bucaran&#x2F;getopts</a>). That is used in Fisherman to make sophisticated CLI apps. It&#x27;s written in sed&#x2F;awk and it&#x27;s <i></i>really<i></i> fast.<p>---<p>This is not even close to all Fisherman has to offer. There other cool things like the [search](<a href="https:&#x2F;&#x2F;github.com&#x2F;fisherman&#x2F;fisherman&#x2F;wiki#search-point_left" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fisherman&#x2F;fisherman&#x2F;wiki#search-point_lef...</a>) command that parses the index file and lets you query plugins like you would expect from any modern tool. In OMF&#x2F;Wahoo (Tacklebox has nothing) you only get a name.<p>---<p>In Fisherman every plugin gets a well deserved `name`, `url`, `description`, any number of `tags` and an `author`&#x27;s name. Makes sense.<p>---<p>And if you install a plugin from an &quot;unknown&quot; URL (one not in [fisher-index](<a href="https:&#x2F;&#x2F;github.com&#x2F;fisherman&#x2F;fisher-index&#x2F;blob&#x2F;master&#x2F;INDEX" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fisherman&#x2F;fisher-index&#x2F;blob&#x2F;master&#x2F;INDEX</a>), Fisherman will complete the information the best it can querying the Git repository, exhausting all the possibilities, so there&#x27;s always data. It even looks at the URL itself and tries to guess stuff.<p>---<p>This &quot;index&quot; thing, is just a plain text flat database written in a human readable format. One cool thing is, the index is <i></i>always<i></i> kept up to date, unlike in OMF where you need to update in order to learn about the new goods. So, you don&#x27;t have to update <i></i>the entire<i></i> application just to see what new packages are available, you are always querying the latest index.<p>---<p>A few other features that to mind is Fishfiles (dependency manifest file) that allows plugins to declare dependencies to other plugins and keep track of what plugins you have installed or not in your system.<p>---<p>BTW, OMF uses a more naive, but still similar, `bundle` file. Fisherman recognizes this and works with it too. No questions asked :+1:<p>---<p>Finally, the bundled <i></i>help<i></i> is phenomenal. Everything ships in glorious `man(1)` pages. You are not alone. Every single feature is thoroughly documented like it should be and now the Wiki is also pretty nice with the screencasts for each command.