mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-28 09:31:16 -03:00
[zfs] Limit snapshots to spelled-out dataset
Use the `-d` parameter to `zfs list` to limit snapshots to the dataset named in the current token being completed. Thanks to @Debilski for the tip. Closes #7472
This commit is contained in:
@@ -5,11 +5,13 @@ function __fish_print_zfs_snapshots -d "Lists ZFS snapshots"
|
||||
# Don't retrieve all snapshots for all datasets until an @ is specified,
|
||||
# or if there is only one possible matching dataset. (See #7472)
|
||||
set current_token (commandline --current-token)
|
||||
set filtered_results (string match -e -- $current_token $fast_results)
|
||||
set current_dataset (string replace -rf "([^@]+)@?.*" '$1' -- $current_token)
|
||||
set filtered_results (string match -ie -- $current_dataset $fast_results)
|
||||
if contains -- --force $argv ||
|
||||
not set -q filtered_results[2] ||
|
||||
string match -eq @ -- $current_token
|
||||
string match -ieq @ -- $current_token ||
|
||||
not set -q filtered_results[2]
|
||||
|
||||
zfs list -t snapshot -o name -H
|
||||
# Ignore errors because the dataset specified could be non-existent
|
||||
zfs list -t snapshot -o name -H -d 1 $current_dataset 2>/dev/null
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user