functions/history: Read the search term if none is given

Fixes #5791.
This commit is contained in:
Fabian Homborg
2019-05-29 21:47:10 +02:00
parent 51fcb79d96
commit c0ca4d3236

View File

@@ -103,25 +103,23 @@ function history --description "display or manipulate interactive command histor
case delete # interactively delete history case delete # interactively delete history
# TODO: Fix this to deal with history entries that have multiple lines. # TODO: Fix this to deal with history entries that have multiple lines.
set -l searchterm $argv
if not set -q argv[1] if not set -q argv[1]
printf (_ "You must specify at least one search term when deleting entries\n") >&2 read -P"Search term: " searchterm
return 1
end end
test -z "$search_mode" test -z "$search_mode"
and set search_mode "--contains" and set search_mode "--contains"
if test $search_mode = "--exact" if test $search_mode = "--exact"
builtin history delete $search_mode $_flag_case_sensitive $argv builtin history delete $search_mode $_flag_case_sensitive $searchterm
return return
end end
# TODO: Fix this so that requesting history entries with a timestamp works: # TODO: Fix this so that requesting history entries with a timestamp works:
# set -l found_items (builtin history search $search_mode $show_time -- $argv) # set -l found_items (builtin history search $search_mode $show_time -- $argv)
set -l found_items set -l found_items
builtin history search $search_mode $_flag_case_sensitive --null -- $argv | while read -lz x set found_items (builtin history search $search_mode $_flag_case_sensitive --null -- $searchterm | string split0)
set found_items $found_items $x
end
if set -q found_items[1] if set -q found_items[1]
set -l found_items_count (count $found_items) set -l found_items_count (count $found_items)
for i in (seq $found_items_count) for i in (seq $found_items_count)