Skip to content

Commit

Permalink
Fixing bug #238 - delete confirmation can be disabled by env variable…
Browse files Browse the repository at this point in the history
… e.g. export HH_CONFIG=noconfirm
  • Loading branch information
dvorka committed Jan 3, 2018
1 parent 079d8f9 commit 85909ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions man/hh.1
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ Configuration options:
\fIprompt-bottom\fR
Show prompt at the bottom of the screen (default is prompt at the top).

\fInoconfirm\fR
Do not ask for confirmation on a history entry delete (default is with confirmation).

\fIregexp\fR
Filter command history using regular expressions (substring match is default)

Expand Down
13 changes: 10 additions & 3 deletions src/hstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
#define HH_CONFIG_KEYWORDS "keywords"
#define HH_CONFIG_SORTING "rawhistory"
#define HH_CONFIG_FAVORITES "favorites"
#define HH_CONFIG_NOCONFIRM "noconfirm"
// MVP: model is the same regardless prompt is top or bottom - view is different
#define HH_CONFIG_PROMPT_BOTTOM "prompt-bottom"
#define HH_CONFIG_BLACKLIST "blacklist"
Expand Down Expand Up @@ -274,6 +275,7 @@ typedef struct {

unsigned char theme;
bool keepPage; // do NOT clear page w/ selection on HH exit
bool noConfirm; // do NOT ask for confirmation on history entry delete
int bigKeys;
int debugLevel;

Expand Down Expand Up @@ -383,6 +385,9 @@ void hstr_get_env_configuration(Hstr *hstr)
if(strstr(hstr_config,HH_CONFIG_KEEP_PAGE)) {
hstr->keepPage=true;
}
if(strstr(hstr_config,HH_CONFIG_NOCONFIRM)) {
hstr->noConfirm=true;
}

if(strstr(hstr_config,HH_CONFIG_DEBUG)) {
hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG;
Expand Down Expand Up @@ -1057,9 +1062,11 @@ void loop_to_select(Hstr *hstr)
msg=malloc(strlen(delete)+1);
strcpy(msg,delete);

print_confirm_delete(msg, hstr);
cc = wgetch(stdscr);
if(cc == 'y') {
if(!hstr->noConfirm) {
print_confirm_delete(msg, hstr);
cc = wgetch(stdscr);
}
if(hstr->noConfirm || cc == 'y') {
deletedOccurences=remove_from_history_model(msg, hstr);
result=hstr_print_selection(maxHistoryItems, pattern, hstr);
print_cmd_deleted_label(msg, deletedOccurences, hstr);
Expand Down

0 comments on commit 85909ec

Please sign in to comment.