You are not logged in.

#1 2016-01-12 11:59:28

heapifyman
Member
Registered: 2016-01-12
Posts: 10

bash completion for maven, rubygems, node, etc.

Hi all,

I'm new to ArchLinux but have some experience with Ubuntu, Fedora and Max OS X. From those OSs I was used to having quite good tab-completion for my dev-tools like maven, rubygems, npm etc.
However, those do not seem to be included in either the respective tool's package or in the bash-completion package.

I think I can just add new completions files to /usr/share/bash-completion/completions but I am wondering:
a) whether /usr/share/bash-completion/completions is the recommended place to put those files or if there some other mechanism I should use, and
b) where I would find a potential file with the corresponding completions.

Thanks in advance for any help.

Offline

#2 2016-01-12 15:07:50

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: bash completion for maven, rubygems, node, etc.

Some packages include bash completions in their packages. A bunch of completion files come from 'bash-completion' package.

I do not see completions for maven, rubygems in the standard repositories. In this case algorithm is following:

- check AUR if there is a package for completion you are looking for
- if it exist then install it otherwise google for an opensource project
- If you found the project then create an AUR package for it.

For example here is maven completion https://github.com/juven/maven-bash-com … etion.bash Try to create an AUR package, it is not difficult at all.


As alternative to package creation you can put the file to /etc/bash_completion.d directory.
Another alternative is to ask maven maintainer to put these completions to maven package directly.


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#3 2016-01-13 00:15:04

heapifyman
Member
Registered: 2016-01-12
Posts: 10

Re: bash completion for maven, rubygems, node, etc.

Hi,

I tried creating an AUR package (inspired by leiningen-completions), which seems to be working locally. Would you mind taking a look at the PKGBUILD before I try to submit it?
I am not sure about what to put as "license". Also namcap warns me that dependencies are not needed. Maybe I'm not getting the purpose of the "depends" property. I understand it as "these packages are necessary for my package to function properly".

# Maintainer: heapifyman <heapifyman@gmail.com>
pkgname=maven-completions
pkgver=0.0.1
pkgrel=1
pkgdesc="Bash completion script for maven"
arch=('any')
url="https://github.com/juven/maven-bash-completion"
license=('unknown')
depends=('maven'
         'bash-completion')
source=("https://raw.githubusercontent.com/juven/maven-bash-completion/03b9f006ddffbe4f6e3913dcf5dab5039822893c/bash_completion.bash")
sha1sums=('ec31a5cdbe9eb061e4158162552f9678c5c083af')

package() {
	cd ${srcdir}
	install -m 0644 -D "${srcdir}"/bash_completion.bash "${pkgdir}"/usr/share/bash-completion/completions/maven
}

Offline

#4 2016-01-13 00:34:34

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: bash completion for maven, rubygems, node, etc.

heapifyman wrote:

I am not sure about what to put as "license".

unknown is okay, but maybe you should contact upstream and ask them to make a note of their licensing terms in the README or something.

heapifyman wrote:

Also namcap warns me that dependencies are not needed. Maybe I'm not getting the purpose of the "depends" property. I understand it as "these packages are necessary for my package to function properly".

Your PKGBUILD looks fine.

See `man namcap` under "depends" for why those warnings don't mean anything.
(Hint: namcap only checks ldd, that's why it is a warning, not an error.)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#5 2016-01-13 11:49:45

heapifyman
Member
Registered: 2016-01-12
Posts: 10

Re: bash completion for maven, rubygems, node, etc.

unknown is okay, but maybe you should contact upstream and ask them to make a note of their licensing terms in the README or something.

Thanks, I will do that.

Offline

#6 2016-01-13 14:55:57

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: bash completion for maven, rubygems, node, etc.

heapifyman wrote:

source=("https://raw.githubusercontent.com/juven/maven-bash-completion/03b9f006ddffbe4f6e3913dcf5dab5039822893c/bash_completion.bash")
sha1sums=('ec31a5cdbe9eb061e4158162552f9678c5c083af')

It should be a VCS package with following version() function

pkgver() {
  cd "$pkgname"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

The package should be called maven-bash-completion-git in this case.

heapifyman wrote:

package() {
    cd ${srcdir}
    install -m 0644 -D "${srcdir}"/bash_completion.bash "${pkgdir}"/usr/share/bash-completion/completions/maven
}

You don't need to cd to $srcdir as makepkg always starts package() in $srcdir.


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#7 2016-01-13 16:01:02

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: bash completion for maven, rubygems, node, etc.

Oh...

Don't cd to $srcdir and then copy a file from $srcdir, that is rather redundant. But if you do, ALWAYS quote the variable! You don't control what is in it...

There is a de facto standard that functions begin in $srcdir, but some like to explicitly cd there anyway (I believe pacman 5.0 will make this de jure).


Upstream doesn't tag versions, so you can either pull arbitrary revisions and increment them yourself or transform the package into a git package as anatolik said. It's a fairly lightweight repo wink so you might just want to make it a git version.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#8 2016-01-14 09:47:59

heapifyman
Member
Registered: 2016-01-12
Posts: 10

Re: bash completion for maven, rubygems, node, etc.

Does this look ok to you?

And if it does, how do I remove the "old" maven-completions from AUR? Just flag it as out of date?

# Maintainer: heapifyman <heapifyman@gmail.com>
pkgname=maven-bash-completion-git
pkgdesc="Bash completion script for maven"
pkgver=r160.e27e290
pkgrel=1
arch=('any')
url="https://github.com/juven/maven-bash-completion"
license=('APACHE')
depends=('maven'
         'bash-completion')
makedepends=('git')
source=("$pkgname::git+https://github.com/juven/maven-bash-completion.git")
sha256sums=('SKIP')

pkgver() {
    cd "$srcdir/$pkgname"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

package() {
	install -m 0644 -D "${srcdir}"/"$pkgname"/bash_completion.bash "${pkgdir}"/usr/share/bash-completion/completions/mvn
}

Offline

#9 2016-01-14 22:12:46

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: bash completion for maven, rubygems, node, etc.

Looks fine. All that is left is subjective style choices, which don't actually affect the usefulness of the PKGBUILD in any way.

in package() --- "${srcdir}"/"$pkgname"  --- could just as easily be "${srcdir}/$pkgname" , also it isn't strictly necessary to bracket that variable, but I like to anyway. I am a bit surprised though, to see a mix of both styles.


A random trick I use for the url/other of git packages is ${pkgname%-git} --- which In my subjective opinion looks nicer (or perhaps just more sophisticated and frilly).

...

I don't think there is any way to change the pkgbase of a package, so just upload this as normal, then submit a deletion request for the other package.
(You can file a merge request instead, which I believe would move comments over to the new package, probably not necessary...)

Last edited by eschwartz (2016-01-14 22:14:07)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#10 2016-01-14 23:00:39

heapifyman
Member
Registered: 2016-01-12
Posts: 10

Re: bash completion for maven, rubygems, node, etc.

A random trick I use for the url/other of git packages is ${pkgname%-git} --- which In my subjective opinion looks nicer (or perhaps just more sophisticated and frilly).

Not sure if I understand what you mean. Could you give an example?

Offline

#11 2016-01-15 00:07:11

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: bash completion for maven, rubygems, node, etc.

Several of my packages are git packages: https://github.com/eli-schwartz/pkgbuilds

See for example the vim-*-git ones. Most of them are by tpope, so the only thing I need to change to add a new one is the pkgname and pkgdesc...
It makes it easy(ier) to repurpose a PKGBUILD.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#12 2016-01-15 09:45:14

heapifyman
Member
Registered: 2016-01-12
Posts: 10

Re: bash completion for maven, rubygems, node, etc.

Ok, got it. Thanks

What do you think of this one now?

# Maintainer: heapifyman <heapifyman@gmail.com>
pkgname=maven-bash-completion-git
pkgdesc="Bash completion script for maven"
pkgver=r160.e27e290
pkgrel=1
arch=('any')
url="https://github.com/juven/${pkgname%-git}"
license=('APACHE')
depends=('maven'
         'bash-completion')
makedepends=('git')
source=("git://github.com/juven/${pkgname%-git}.git")
sha256sums=('SKIP')

pkgver() {
    cd "${srcdir}/${pkgname%-git}"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

package() {
	install -m 0644 -D "${srcdir}/${pkgname%-git}"/bash_completion.bash "${pkgdir}"/usr/share/bash-completion/completions/mvn
}

Offline

#13 2016-01-15 18:28:26

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: bash completion for maven, rubygems, node, etc.

A brilliant homage to my style preferences. big_smile


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB