2017-11-23 12:55:59 +00:00
|
|
|
function __fish_print_zfs_snapshots -d "Lists ZFS snapshots"
|
2020-11-13 04:19:05 +00:00
|
|
|
set fast_results (zfs list -o name -H)
|
|
|
|
printf "%s\n" $fast_results
|
|
|
|
|
|
|
|
# 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)
|
2020-11-20 21:28:19 +00:00
|
|
|
set current_dataset (string replace -rf "([^@]+)@?.*" '$1' -- $current_token)
|
|
|
|
set filtered_results (string match -ie -- $current_dataset $fast_results)
|
2020-11-13 04:19:05 +00:00
|
|
|
if contains -- --force $argv ||
|
2020-11-22 13:39:48 +00:00
|
|
|
string match -ieq @ -- $current_token ||
|
|
|
|
not set -q filtered_results[2]
|
2020-11-13 04:19:05 +00:00
|
|
|
|
2020-11-20 21:28:19 +00:00
|
|
|
# Ignore errors because the dataset specified could be non-existent
|
|
|
|
zfs list -t snapshot -o name -H -d 1 $current_dataset 2>/dev/null
|
2020-11-13 04:19:05 +00:00
|
|
|
end
|
2017-11-23 12:55:59 +00:00
|
|
|
end
|