Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated bash completions and sudoers #98

Closed
wants to merge 8 commits into from
Closed

Updated bash completions and sudoers #98

wants to merge 8 commits into from

Conversation

Aneurin
Copy link

@Aneurin Aneurin commented Sep 11, 2013

I recently realised that my bash completions are being shipped as part of the Debian packages for ZoL, which prompted me to make some updates.

These completions still aren't complete, but they now include full-featured completions for more of the commands (basically any which I use with any regularity in my day job). Existing completions are greatly improved over the original, significantly more useful if you have a lot of snapshots, and somewhat better in the case where you don't have access to /dev/zfs, but do have passwordless sudo set up for read-only commands, as suggested by ZoL.

I'm not sure if you actually use this repo as a working area at all, plus I recognise that having a number of commits for such a small feature might be an inappropriate level of detail, so feel free to ignore the pull request and just grab the file if you prefer.

Check whether /dev/zfs is writable, and prefix zfs commands with sudo if
not. Far from bulletproof, but an incremental improvement nevertheless.
I don't want to try and make it *too* smart as the completions need to
load as nearly instantaneously as possible; this should at least cover
the most common cases.

Also, don't include snapshots in general-purpose completions (get,
inherit, list) by default. This makes working with large numbers of
snapshots considerably easier.
The completion script now has some understanding of the switches to
these commands, and does a better job with comma-separated argument
lists.
These can be arbitrary values, and contain a colon, so need to be
handled specially as bash considers the colon to be a token separator.
This is just a first pass, allowing the possibility to complete snapshot
names without first having to build a list of every snapshot on the
system, and using the facility to flesh out the completion for zfs
clone, rollback, and send.
It's now possible to get snapshot names expanded if the current argument
ends with an @, in places which previously wouldn't expand snapshots for
performance reasons.
Most notably a slightly less cumbersome way of specifying the switches
available for a given command.
This makes the code more consistent and a little cleaner.

(Plus builtins are faster, not that that's likely to result in any
practical difference.)

There are still some uses of expr in places where it looked like the
most concise readable option.
@dajhorn
Copy link
Member

dajhorn commented Sep 11, 2013

@Aneurin, I merged this into my working snapshot/ubuntu/precise branch for testing. Thanks for the update.

@FransUrbo
Copy link
Contributor

@Aneurin could you rebase this against snapshot/debian/wheezy/0.6.3-0.9_g540ce4_wheezy? I've completely missed this one.

@Aneurin
Copy link
Author

Aneurin commented Mar 5, 2014

@FransUrbo Er, a couple of months ago I got kind of confused and frustrated by all of the branching in ZoL, and decided that since it's not ZoL specific anyway, I'd keep it separately.

Since it's only one file, your best bet would probably be just to grab the current version from https://github.com/Aneurin/zfs-bash/blob/master/zfs_completion.bash

@dajhorn
Copy link
Member

dajhorn commented Apr 10, 2014

@Aneurin, I pulled anuerin/zfs-bash directly into pkg-zfs for Ubuntu and preserved your history here: 89858d6

Your commits should appear verbatim if you click the parent link.

@dajhorn dajhorn closed this Apr 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants