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
Updated bash completions and sudoers #98
Conversation
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.
|
@Aneurin, I merged this into my working snapshot/ubuntu/precise branch for testing. Thanks for the update. |
|
@Aneurin could you rebase this against |
|
@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 |
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.