Fossil Forum

Seriously awesome context-sensitive ZSH completion for Fossil
Login

Seriously awesome context-sensitive ZSH completion for Fossil

Seriously awesome context-sensitive ZSH completion for Fossil

(1.1) By Lifepillar (lifepillar) on 2020-10-24 14:47:53 edited from 1.0 [source]

I couldn't find anything related to the spammy sounding subject, so this weekend I have cooked my own function. I don't know what would be the best public place for such a thing (Chiselapp? Oh-my-ZSH? Fossil itself?), so for now it's available as a gist… on GitHub:

https://gist.github.com/lifepillar/291e3557431929e1a999ef877a5e1d6c

Edit: this gist was deleted. See later in this thread for a new link.

I don't understand much of the way too complicated ZSH system, but the result should make Git completion pale in comparison :-D

Given Fossil's articulated commands and the heterogeneous styles of the help files (discussed a couple of years ago in this forum), the only reliable way to build context-sensitive completion was patient hand-crafted work. The file is long, but the structure is not that complicated and can be updated easily. I hope that the ZSH users among you will appreciate it!

There is still room for improvement (especially for some less common commands). Please point out what you think could be improved.

(2) By Stephan Beal (stephan) on 2020-10-18 13:43:51 in reply to 1.0 [link] [source]

so for now it's available as a gist… on GitHub:

i'm not 100% certain of this, but we "might" not need a contributor agreement from you in order to include that (being a completely independent external script) in the main fossil repo. That's a question Richard would need to answer, though, before one of us goes a plops it in there.

(3) By Lifepillar (lifepillar) on 2020-10-18 18:05:05 in reply to 2 [link] [source]

I've placed the code in the public domain (that's mentioned in the file): you may do whatever you want with it, even without attribution.

(4) By Stephan Beal (stephan) on 2020-10-18 18:49:08 in reply to 3 [link] [source]

I've placed the code in the public domain (that's mentioned in the file): you may do whatever you want with it, even without attribution.

Unfortunately that doesn't protect/indemnify the project, as some jurisdictions (such as Germany, where i live) don't recognize Public Domain dedications :/.

(5) By Lifepillar (lifepillar) on 2020-10-19 15:37:05 in reply to 4 [link] [source]

Well, no problem changing the license terms, if that's an issue.

(6) By Stephan Beal (stephan) on 2020-10-19 15:50:14 in reply to 5 [link] [source]

Well, no problem changing the license terms, if that's an issue.

i'm not 100% certain what Richard's license requirements are for inclusion of such material, but...

We have a copy of bootstrap's CSS in the tree and it has an MIT license header, so we have a years-old precedent for 3rd-party material with that license:

/*!
* Bootstrap v3.3.2 (http://getbootstrap.com)
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/

https://fossil-scm.org/fossil/finfo?name=skins/bootstrap/css.txt

https://opensource.org/licenses/MIT

MIT is essentially as close to public domain as a license can get, requiring only that the copyright/license blurb remains intact.

(7) By ddumitriu on 2020-10-19 16:24:23 in reply to 6 [link] [source]

Maybe CC0, or MIT. Or simply BSD2 like fossil?

(8) By Stephan Beal (stephan) on 2020-10-19 16:42:02 in reply to 7 [link] [source]

Or simply BSD2 like fossil?

i was wondering about that as well, but don't know if that suffices for purposes of protecting the project and/or Richard. We have a precedent of including MIT stuff, in any case, so that one should be fine.

(9) By Lifepillar (lifepillar) on 2020-10-24 14:55:23 in reply to 8 [link] [source]

I have updated the script (it completes test commands!) and its license (MIT). Besides, I have deleted the gist on GitHub and I have created a repo on Chisel. So, the new official home for the script is:

https://chiselapp.com/user/lifepillar/repository/fossil-zsh-completion/

I would like to receive email notifications if someone opens a ticket. Anyone willing to make a crash course for a beginner on how to do that? :-) Are there settings that it is best to change from their default when publishing a repository on the wild Internet?

(10) By Stephan Beal (stephan) on 2020-10-25 01:57:49 in reply to 9 [link] [source]

https://chiselapp.com/user/lifepillar/repository/fossil-zsh-completion/

If there are no objections from yourself or the other developers i will drop that into our "tools" directory within the next couple of days. It seems we already have a variant for bash.

I would like to receive email notifications if someone opens a ticket.

That can be configured via the /alerts page. That said, it requires that the "backoffice" supports that, and i've never gotten that working on my hoster, nor do i have any idea whether chissel supports it (nor how to set it up there).

Are there settings that it is best to change from their default when publishing a repository on the wild Internet?

i always double-check that "anonymous" has zero write permissions, e.g. no wiki edit/append (you'll probably want to allow ticket creation, though). Way back when, though i'm unsure whether it was through a weird default or my own error, i saw an anonymous account edit wiki pages on a couple repos and inject spam links into them.

(11) By Lifepillar (lifepillar) on 2020-10-25 11:40:55 in reply to 10 [link] [source]

If there are no objections from yourself

There are none. As per the license, you may do basically what you want with the code. I will keep the Chisel repo online anyway, in case you decide to ignore it.

That can be configured via the /alerts page. That said, it requires that the "backoffice" supports that

Can such "backoffice" be configured via /setup_smtpd? That is, does Fossil include an SMTP server? Or does that assume that an SMTP server is already running in the server? According to what I have read, I'd say the latter, but /setup_smtpd is described as a "built-in email server". Maybe, I should read the documentation more carefully…

(12) By Warren Young (wyoung) on 2020-10-25 14:49:39 in reply to 11 [link] [source]

does Fossil include an SMTP server?

Not one that's fully functional and useful on the modern Internet. You'd have to ask drh what his plans are for bringing it to a state where it's functional enough that it can successfully deliver mail to N-nines percent of the existing Internet SMTP infrastructure. It would also be interesting to know his value for N.

Currently, you cannot select Fossil's nascent internal SMTP server as a send method in the Email Alerts (a.k.a. Notification) feature.

I should read the documentation more carefully…

Yes. The above question was briefly answered by it here. I've checked the code, and that section is still correct.

(13) By Stephan Beal (stephan) on 2020-10-26 06:49:02 in reply to 10 [link] [source]

If there are no objections from yourself or the other developers i will drop that into our "tools" directory within the next couple of days.

It's been added. By comparison, the bash version is only about 544 bytes, but isn't carefully curated like yours is.

Yours was modified only to add the original source URL to the comments.

(14) By seeg on 2020-11-12 05:21:30 in reply to 13 [link] [source]

Ah, maybe someone will know how to fix my pull request to oh-my-zsh then: https://github.com/ohmyzsh/ohmyzsh/pull/8564

Basically it's about autocompleting files with spaces inside. If I have, say, a file named a b.txt then using fossil add <TAB> will result in 2 completions: a and b.txt. I'm not that proficient with ZSH to do this myself. :)

(15) By Scott Robison (sdr) on 2020-11-12 05:56:17 in reply to 14 [link] [source]

I would encourage you not to create files with spaces in them if you can possibly avoid it. I know that doesn't solve this particular issue you've brought up, and it would be nice if this autocompletion module quoted names properly, but if you don't put unexpected characters like spaces in a file name, you never have to worry about that defect as you move from computer to computer, some of which might not be configured to your liking.

(16) By Lifepillar (lifepillar) on 2020-11-12 19:56:44 in reply to 14 [link] [source]

Ah, maybe someone will know how to fix my pull request to oh-my-zsh

You may try adding

local IFS=$'\n'

before calling compadd. There may be better ways, though.