File src/hstr.c changed (mode: 100644) (index a704ca4..bc77a60) |
97 |
97 |
|
|
98 |
98 |
#define HH_CONFIG_THEME_MONOCHROMATIC "monochromatic" |
#define HH_CONFIG_THEME_MONOCHROMATIC "monochromatic" |
99 |
99 |
#define HH_CONFIG_THEME_HICOLOR "hicolor" |
#define HH_CONFIG_THEME_HICOLOR "hicolor" |
100 |
|
#define HH_CONFIG_CASE "casesensitive" |
|
101 |
|
#define HH_CONFIG_REGEXP "regexp" |
|
102 |
|
#define HH_CONFIG_SUBSTRING "substring" |
|
103 |
|
#define HH_CONFIG_KEYWORDS "keywords" |
|
104 |
|
#define HH_CONFIG_SORTING "rawhistory" |
|
105 |
|
#define HH_CONFIG_FAVORITES "favorites" |
|
106 |
|
#define HH_CONFIG_NOCONFIRM "noconfirm" |
|
107 |
|
// MVP: model is the same regardless prompt is top or bottom - view is different |
|
|
100 |
|
#define HH_CONFIG_CASE "casesensitive" |
|
101 |
|
#define HH_CONFIG_REGEXP "regexp" |
|
102 |
|
#define HH_CONFIG_SUBSTRING "substring" |
|
103 |
|
#define HH_CONFIG_KEYWORDS "keywords" |
|
104 |
|
#define HH_CONFIG_SORTING "rawhistory" |
|
105 |
|
#define HH_CONFIG_FAVORITES "favorites" |
|
106 |
|
#define HH_CONFIG_NOCONFIRM "noconfirm" |
|
107 |
|
#define HH_CONFIG_VERBOSE_KILL "verbose-kill" |
108 |
108 |
#define HH_CONFIG_PROMPT_BOTTOM "prompt-bottom" |
#define HH_CONFIG_PROMPT_BOTTOM "prompt-bottom" |
109 |
|
#define HH_CONFIG_BLACKLIST "blacklist" |
|
110 |
|
#define HH_CONFIG_KEEP_PAGE "keep-page" |
|
111 |
|
#define HH_CONFIG_DEBUG "debug" |
|
112 |
|
#define HH_CONFIG_WARN "warning" |
|
|
109 |
|
#define HH_CONFIG_BLACKLIST "blacklist" |
|
110 |
|
#define HH_CONFIG_KEEP_PAGE "keep-page" |
|
111 |
|
#define HH_CONFIG_DEBUG "debug" |
|
112 |
|
#define HH_CONFIG_WARN "warning" |
113 |
113 |
#define HH_CONFIG_BIG_KEYS_SKIP "big-keys-skip" |
#define HH_CONFIG_BIG_KEYS_SKIP "big-keys-skip" |
114 |
114 |
#define HH_CONFIG_BIG_KEYS_FLOOR "big-keys-floor" |
#define HH_CONFIG_BIG_KEYS_FLOOR "big-keys-floor" |
115 |
115 |
#define HH_CONFIG_BIG_KEYS_EXIT "big-keys-exit" |
#define HH_CONFIG_BIG_KEYS_EXIT "big-keys-exit" |
|
... |
... |
static const char *INSTALL_ZSH_STRING= |
222 |
222 |
"\nexport HISTFILE=~/.zsh_history # ensure history file visibility" |
"\nexport HISTFILE=~/.zsh_history # ensure history file visibility" |
223 |
223 |
"\nexport HH_CONFIG=hicolor # get more colors" |
"\nexport HH_CONFIG=hicolor # get more colors" |
224 |
224 |
"\nbindkey -s \"\\C-r\" \"\\eqhh\\n\" # bind hh to Ctrl-r (for Vi mode check doc)" |
"\nbindkey -s \"\\C-r\" \"\\eqhh\\n\" # bind hh to Ctrl-r (for Vi mode check doc)" |
225 |
|
// TODO try variant with arg/pars separation |
|
|
225 |
|
// TODO try variant with args/pars separation |
226 |
226 |
//"\nbindkey -s \"\\C-r\" \"\\eqhh --\\n\" # bind hh to Ctrl-r (for Vi mode check doc)" |
//"\nbindkey -s \"\\C-r\" \"\\eqhh --\\n\" # bind hh to Ctrl-r (for Vi mode check doc)" |
227 |
227 |
// alternate binding options in zsh: |
// alternate binding options in zsh: |
228 |
228 |
// bindkey -s '^R' '^Ahh ^M' |
// bindkey -s '^R' '^Ahh ^M' |
|
... |
... |
typedef struct { |
288 |
288 |
unsigned char theme; |
unsigned char theme; |
289 |
289 |
bool keepPage; // do NOT clear page w/ selection on HH exit |
bool keepPage; // do NOT clear page w/ selection on HH exit |
290 |
290 |
bool noConfirm; // do NOT ask for confirmation on history entry delete |
bool noConfirm; // do NOT ask for confirmation on history entry delete |
|
291 |
|
bool verboseKill; // write a message on delete of the last command in history |
291 |
292 |
int bigKeys; |
int bigKeys; |
292 |
293 |
int debugLevel; |
int debugLevel; |
293 |
294 |
|
|
|
... |
... |
void hstr_get_env_configuration(Hstr *hstr) |
391 |
392 |
hstr->bigKeys=RADIX_BIG_KEYS_SKIP; |
hstr->bigKeys=RADIX_BIG_KEYS_SKIP; |
392 |
393 |
} |
} |
393 |
394 |
} |
} |
|
395 |
|
if(strstr(hstr_config,HH_CONFIG_VERBOSE_KILL)) { |
|
396 |
|
hstr->verboseKill=true; |
|
397 |
|
} |
394 |
398 |
if(strstr(hstr_config,HH_CONFIG_BLACKLIST)) { |
if(strstr(hstr_config,HH_CONFIG_BLACKLIST)) { |
395 |
399 |
hstr->blacklist.useFile=true; |
hstr->blacklist.useFile=true; |
396 |
400 |
} |
} |
|
... |
... |
void hstr_getopt(int argc, char **argv, Hstr *hstr) |
1429 |
1433 |
hstr->interactive=false; |
hstr->interactive=false; |
1430 |
1434 |
break; |
break; |
1431 |
1435 |
case 'k': |
case 'k': |
1432 |
|
if(history_mgmt_remove_last_history_entry()) { |
|
|
1436 |
|
if(history_mgmt_remove_last_history_entry(hstr->verboseKill)) { |
1433 |
1437 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
1434 |
1438 |
} else { |
} else { |
1435 |
1439 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
File src/hstr_history.c changed (mode: 100644) (index 3c1280f..a01e66e) |
... |
... |
int history_mgmt_remove_from_system_history(char *cmd) |
263 |
263 |
return occurences; |
return occurences; |
264 |
264 |
} |
} |
265 |
265 |
|
|
266 |
|
bool history_mgmt_remove_last_history_entry() |
|
|
266 |
|
bool history_mgmt_remove_last_history_entry(bool verbose) |
267 |
267 |
{ |
{ |
268 |
268 |
using_history(); |
using_history(); |
269 |
269 |
|
|
|
... |
... |
bool history_mgmt_remove_last_history_entry() |
276 |
276 |
// delete the last command + the command that was used to run HSTR |
// delete the last command + the command that was used to run HSTR |
277 |
277 |
if(historyState->length > 1) { |
if(historyState->length > 1) { |
278 |
278 |
// length is NOT updated on history entry removal |
// length is NOT updated on history entry removal |
|
279 |
|
if(verbose) { |
|
280 |
|
fprintf(stdout, "Deleting command '%s' from history\n", historyState->entries[historyState->length-2]->line); |
|
281 |
|
} |
279 |
282 |
free_history_entry(remove_history(historyState->length-1)); |
free_history_entry(remove_history(historyState->length-1)); |
280 |
283 |
free_history_entry(remove_history(historyState->length-2)); |
free_history_entry(remove_history(historyState->length-2)); |
281 |
284 |
write_history(get_history_file_name()); |
write_history(get_history_file_name()); |
282 |
285 |
return true; |
return true; |
283 |
286 |
} |
} |
|
287 |
|
if(verbose) { |
|
288 |
|
fprintf(stderr, "Unable to delete the last command from history.\n"); |
|
289 |
|
} |
284 |
290 |
return false; |
return false; |
285 |
291 |
} |
} |
286 |
292 |
|
|
File src/include/hstr_history.h changed (mode: 100644) (index 34c82e4..d7a4a87) |
... |
... |
void free_prioritized_history(void); |
60 |
60 |
void history_mgmt_open(void); |
void history_mgmt_open(void); |
61 |
61 |
void history_clear_dirty(void); |
void history_clear_dirty(void); |
62 |
62 |
int history_mgmt_remove_from_system_history(char *cmd); |
int history_mgmt_remove_from_system_history(char *cmd); |
63 |
|
bool history_mgmt_remove_last_history_entry(); |
|
|
63 |
|
bool history_mgmt_remove_last_history_entry(bool verbose); |
64 |
64 |
int history_mgmt_remove_from_raw(char *cmd, HistoryItems *history); |
int history_mgmt_remove_from_raw(char *cmd, HistoryItems *history); |
65 |
65 |
int history_mgmt_remove_from_ranked(char *cmd, HistoryItems *history); |
int history_mgmt_remove_from_ranked(char *cmd, HistoryItems *history); |
66 |
66 |
void history_mgmt_flush(void); |
void history_mgmt_flush(void); |