diff --git a/builtin.cpp b/builtin.cpp index 959fc8437..393cb3081 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -3614,6 +3614,7 @@ static int builtin_history( parser_t &parser, wchar_t **argv ) { L"contains", required_argument, 0, 'c' }, { L"save", no_argument, 0, 'v' }, { L"clear", no_argument, 0, 'l' }, + { L"help", no_argument, 0, 'h' }, { 0, 0, 0, 0 } }; @@ -3646,6 +3647,10 @@ static int builtin_history( parser_t &parser, wchar_t **argv ) case 'l': clear_history = true; break; + case 'h': + builtin_print_help( parser, argv[0], stdout_buffer ); + return STATUS_BUILTIN_OK; + break; case '?': append_format(stderr_buffer, BUILTIN_ERR_UNKNOWN, argv[0], argv[woptind-1]); return STATUS_BUILTIN_ERROR; diff --git a/doc_src/history.txt b/doc_src/history.txt index 7b00bea68..8f7b69164 100644 --- a/doc_src/history.txt +++ b/doc_src/history.txt @@ -3,34 +3,34 @@ \subsection history-synopsis Synopsis
history (--save | --clear) -history (--search | --delete ) (--prefix "prefix string" | --search "search string") +history (--search | --delete ) (--prefix "prefix string" | --contains "search string")\subsection history-description Description -history is used to list, search and delete user's command history. +history is used to list, search and delete user's command history \subsection history-examples Example
history --save -Save all changes in history file. +Save all changes in history file history --clear -Delete all history items. +Delete all history items history --search --contains "foo" -Searches commands containing "foo" string. +Searches commands containing "foo" string history --search --prefix "foo" -Searches for commands with prefix "foo". +Searches for commands with prefix "foo" history --delete --contains "foo" -Interactively delete commands containing string "foo". +Interactively delete commands containing string "foo" history --delete --prefix "foo" -Interactively delete commands with prefix "foo". +Interactively delete commands with prefix "foo" history --delete "foo" -Delete command "foo" from history. +Delete command "foo" from historydiff --git a/history.cpp b/history.cpp index 73d14fc2c..c271b32e8 100644 --- a/history.cpp +++ b/history.cpp @@ -406,8 +406,6 @@ void history_t::remove(const wcstring &str) break; } } - - save(); } void history_t::get_string_representation(wcstring &result, const wcstring &separator) diff --git a/share/functions/history.fish b/share/functions/history.fish index b71931c0c..7383f52ef 100644 --- a/share/functions/history.fish +++ b/share/functions/history.fish @@ -54,6 +54,9 @@ function history --description "Deletes an item from history" set found_items (builtin history --search --contains $contains_args) case none builtin history $argv + + #Save changes after deleting item + builtin history --save return 0 end @@ -101,8 +104,12 @@ function history --description "Deletes an item from history" else builtin history --delete $found_items[(math $i - 1)] end + end end + + #Save changes after deleting item(s) + builtin history --save end case save #Save changes to history file