News for hackers. Stuff that matters.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by homebrewer on Sunday August 10, 2025 @06:34AM (#44854235)
With fish, if the program you're interested in hasn't betrayed the decades-old tradition of shipping man pages, it's often as simple as running `fish_update_completions`.

It parses all man pages on your system and generates completion files for you. By default, they go into ~/.cache/fish/generated_completions/*

If the man page was written poorly/is missing, you can always write your own completion (and hopefully send it upstream). fish uses such a simple format that I don't think there's any need for tutorials save the official doc:

https://fishshell.com/docs/current/completions.html

For example, here's an excerpt from curl

  complete --command curl --short-option 'L' --long-option 'location' --description 'Follow redirects' 
  complete --command curl --short-option 'O' --long-option 'remote-name' --description 'Write output to file named as remote file'
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by btreecat on Sunday August 10, 2025 @06:47AM (#44854299)
When I screen share, people don't realize I'm not using zsh and dozen plugins. It's just fish and it's beautiful out of the box.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by kekebo on Sunday August 10, 2025 @07:22AM (#44854453)
Thank you for the comment. https://github.com/umlx5h/zsh-manpage-completion-generator appears to adapt this to ZSH. Have yet to try through
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by cb321 on Sunday August 10, 2025 @08:43AM (#44854808)
For those programs that have betrayed shipping man pages, instead say relying only on a --help system, do you happen to know if the fish shell has an analogue to Zsh `_gnu_generic` and Bash `complete -F _longopt`? If not, do you have any insight into why not/what it would take to make that happen?
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by mr_mitm on Sunday August 10, 2025 @09:39AM (#44855124)
At least for a subset of Python CLI programs, I wrote this: https://github.com/AdrianVollmer/pycompgen

Still in an early stage, but it should work.

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by nikita2206 on Sunday August 10, 2025 @09:04AM (#44854915)
The OP mentions them in the last part of their comment, there is `complete …` commands for registering completions
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by cb321 on Sunday August 10, 2025 @09:16AM (#44854995)
It sounds like you don't know how the Bash/Zsh ideas I mentioned work. They run the command with --help, parse the output, and from that generate the completions, wiring them in to the completion system. That method is a zero config solution (well, you might need a list of such "command-names only" - no option names, which could change at any time -- so maybe "minimal config"). The OP & you mention a much heavier config solution which strikes me as against the vibe of Fish in general which is, supposedly, out-of-the-box niceness.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by jnpnj on Sunday August 10, 2025 @09:19AM (#44855013)
oh wow, it's parsing all 9461 man pages on my arch install, for a cute total of 13MB

thanks a lot

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by sanewombat on Sunday August 10, 2025 @09:37AM (#44855114)
It's surprising that on OpenSUSE `zypper search fish-completion` returns more than 200 packages. Something is fishy here.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by OptionOfT on Sunday August 10, 2025 @10:22AM (#44855384)
That is to get live data in your completions.

Say you have a widget that has 3 commands: list, start and stop.

With one of those completion files widget stop <tab> will show you a tab-able list of widgets which are running.

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by IgorPartola on Sunday August 10, 2025 @10:07AM (#44855281)
man pages are so underrated. I mean every project nowadays has README.md so I don’t see why we can’t just auto generate them with or without an LLM helping. Also I wish programs would use standardized generic arguments for help, config file, version, background the task, PID file, log file, and log level.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by yencabulator on Sunday August 10, 2025 @12:02PM (#44856093)
I'll switch to fish after it stops expanding `car TAB` to `blkdiscard` when I don't have `cargo` in path. Non-prefix completion for commands is plain evil.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by dingnuts on Sunday August 10, 2025 @01:55PM (#44856953)
I bet this is configurable but I wanted to say that this is totally personal preference; I have the exact opposite opinion. Prefix only matching requires much more tab slapping in my experience.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by yencabulator on Sunday August 10, 2025 @02:16PM (#44857109)
I believe you would lose that bet. I look every few years and I don't see it
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by natebc on Sunday August 10, 2025 @02:56PM (#44857356)
interestingly this also seems to have come up pretty recently in their discussions.

https://github.com/fish-shell/fish-shell/discussions/11670#d...

> I'm not sure that subsequence matching ever produces results that people expect (I feel like we've discussed this before but haven't had time to go digging)

No solution, but the discussion seems positive, from a maintainer too.

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by thiht on Sunday August 10, 2025 @04:49PM (#44858160)
I gave up on fish after a few weeks because of a similar preference issue where the fish maintainers flat out refused to make a bad default configurable: https://github.com/fish-shell/fish-shell/issues/8618

> We don't really do config flags like this, as a philosophical point.

> I would be against accepting such a PR. I do not believe this should be changed.

I understand that they want to keep the list of configs short and manageable, but it means that's not a tool for me. I'm all for good, opinionated defaults but I want to be able to make some changes if I want to.

They apparently reconsidered and implemented the change since migrating fish to rust though.

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by wpm on Sunday August 10, 2025 @03:24PM (#44857540)
I’ll switch to fish when it comes preinstalled on all of the computers I use so I can write scripts in it.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by yencabulator on Sunday August 10, 2025 @03:53PM (#44857778)
I already avoid bash scripting so I lose very little. Shell scripting beyond throwaway one-liners is a problem not a solution.

(Well that and all my machines come from the same NixOS configs.)

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by nothrabannosir on Sunday August 10, 2025 @06:21PM (#44858811)
Ha that’s funny, considering nixos is 99% stdenv which is one of the worst bash monstrosities in existence, and drives people ever further into the swamp of bash. (Ever tried to debug stdenv setup hooks? I still have water damage from the tears.)

I have personally embraced the insanity but let’s not kid ourselves about nixos basically just being three bashes in a trench coat.

Basically https://xkcd.com/224/ , but s/lisp/nix/ s/perl/bash/

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by yencabulator on Sunday August 10, 2025 @07:41PM (#44859467)
It's my daily driver, but I am holding my nose.

Some year something better will show up from someone with more taste (and I know I am not alone in having thoughts on what it would look like), but for now the yak has already been shaven. At least the builds are sandboxed.

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by nothrabannosir on Monday August 11, 2025 @12:27AM (#44860748)
Guix if you can stomach it.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by kstrauser on Sunday August 10, 2025 @07:12PM (#44859226)
Do you really limit your shell experience to plain POSIX? That sounds masochistic.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by fmbb on Monday August 11, 2025 @02:15AM (#44861193)
Ever since shellcheck came around I have been writing all my scripts in POSIX sh. Its not that bad actually and knowing stuff is just more compatible is worth that little friction.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by hoherd on Monday August 11, 2025 @09:07AM (#44863657)
Shellcheck has been a huge game changer for me. The lack of a linter is the main reason I don't consider switching to zsh anymore.

When I first found shellcheck, I'd sit on the train every morning and fix all the stupid little bugs in all our shell code. I learned a TON about shell scripting, because the shellcheck wiki is amazing. We had some redhat 6 init scripts checked into our repos, and shellcheck helpd me find syntax errors in those init scripts. If Redhat can't reliably write shell scripts without a linter, or catch bugs from upstream, what makes us think we're any better?

I wouldn't write serious programs in another language without a linter. Why should I write shell scripts without one?

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by Max-Limelihood on Monday August 11, 2025 @11:58PM (#44872262)
You shouldn't be writing serious programs in Bash/Zsh at all, is the issue. If it's complex enough to need linting, it's complex enough to require Python/Perl.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by kstrauser on Monday August 11, 2025 @11:17AM (#44865109)
Writing all your scripts that way is one thing. I’m not that far off, although I write all my shell functions and things like that in fish. But avoiding using tools that may not be universally available means never using ripgrep or fd or fish or newer versions of bash or any of the other nice updates we have now, and that sounds awful.
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by wpm on Tuesday August 12, 2025 @12:08AM (#44872317)
I would rather limit myself to things I know are going to be preinstalled on the platforms I use than deal with the masochism that is scripted dependency management. No thanks.

All these comments here "Uhhh just use PythoN!" Yeah? I write scripts that need to run on macOS. No Python there. Yeah I can have my script sit there and pull the command line tools in an automated way and wait the 20 minutes it takes to install or I can pull on my big boy pants and just figure out how to do it in shell. It's turing complete. It works. Whatever.

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by pirates on Tuesday August 12, 2025 @06:45AM (#44874607)
MacOS doesn’t have python? What?
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by wpm on Tuesday August 12, 2025 @09:55AM (#44876233)
macOS has not shipped with Python installed in 6 years. If you take a Mac out of the box, open terminal, and run `python` it prompts you in the GUI to install the Command Line Developer Tools.

Thanks GPLv3

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by znpy on Thursday August 14, 2025 @06:00PM (#44906204)
there's Perl though :)
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by Max-Limelihood on Tuesday August 12, 2025 @12:15AM (#44872353)
That's why I use C to write all my shell scripts. Can't have something non-portable like bash, which is missing from 75% of computers by default.

(Seriously, what am I missing here? Is `apt-brew pacman install fish` really that hard to type? If cross-platform portability is actually a concern, shouldn't you be using Python anyway?)

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by wpm on Wednesday August 13, 2025 @11:34AM (#44889832)
I don't really care about portability as I do "how much shit do I need to install to actually get work done on my workstations and servers"

Maybe it's because I was a sysadmin in a former life, but overmanaging is almost always a mistake. If I had one single computer and only one, sure, who cares. But I have a homelab full of servers and a constant churn of VMs and I don't need to add in another step of "oh shit X isn't installed yet". Maybe it's also because of that that I don't really give a shit about how "bad" sh/bash/zsh are.

Yes, I can sync dotfiles and crap to git (which I also have to install to use), but it's just a small weight off my shoulders to not have to worry or think about that shit before I can use a server or workstation. I don't want to have to unlearn normal shell to learn fish and then have to switch back when I'm trying to get some thing online so that I can install fish. I'm just not fuckin interested.

(inb4 someone is like nix solves this, i don't give a shit about nix either)

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by znpy on Thursday August 14, 2025 @05:41PM (#44906025)
i'll just stick to bash
Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by fishywang on Sunday August 10, 2025 @10:55PM (#44860411)
I tried to use fish on some of my debian servers that i only rarely update packages/kernel, so I don't have to carry my bashrc there, but found their completion for apt is pretty naive. for example after updated kernel i would want to clean up the old ones, but `apt purge linux-image-<TAB>` would list all available kernel versions, not just the ones currently installed.

in the end i switched back to bash.

Re:Writing Your Own Simple Tab-Completions for Bash and Zsh by hnlmorg on Monday August 11, 2025 @03:19AM (#44861541)
Fish isn’t the only shell that does this. Murex has supported man page completions for years too. And it’s fully automatic in Murex.