Add history ignore (#846)

This commit is contained in:
Yoav 2018-12-31 01:35:00 +02:00 committed by Quentin Glidic
parent aacb570850
commit 238648b5b2
5 changed files with 21 additions and 0 deletions

View File

@ -91,6 +91,8 @@ Settings config = {
.fixed_num_lines = TRUE, .fixed_num_lines = TRUE,
/** Do not use history */ /** Do not use history */
.disable_history = FALSE, .disable_history = FALSE,
/** Programs ignored for history */
.ignored_prefixes = "",
/** Sort the displayed list */ /** Sort the displayed list */
.sort = FALSE, .sort = FALSE,
/** Use levenshtein sorting when matching */ /** Use levenshtein sorting when matching */

View File

@ -36,6 +36,7 @@
* *
* This uses the following options from the #config object: * This uses the following options from the #config object:
* * #Settings::disable_history * * #Settings::disable_history
* * #Settings::ignored_prefixes
* *
* @{ * @{
*/ */

View File

@ -108,6 +108,8 @@ typedef struct
unsigned int fixed_num_lines; unsigned int fixed_num_lines;
/** Do not use history */ /** Do not use history */
unsigned int disable_history; unsigned int disable_history;
/** Programs ignored for history */
char * ignored_prefixes;
/** Toggle to enable sorting. */ /** Toggle to enable sorting. */
unsigned int sort; unsigned int sort;
/** Sorting method. */ /** Sorting method. */

View File

@ -180,6 +180,20 @@ void history_set ( const char *filename, const char *entry )
if ( config.disable_history ) { if ( config.disable_history ) {
return; return;
} }
// Check if program should be ignored
for ( char *checked_prefix = strtok ( config.ignored_prefixes, ";" ); checked_prefix != NULL; checked_prefix = strtok ( NULL, ";" ) ) {
// For each ignored prefix
while ( g_unichar_isspace ( g_utf8_get_char ( checked_prefix ) ) ) {
checked_prefix = g_utf8_next_char ( checked_prefix ); // Some users will probably want "; " as their separator for aesthetics.
}
if ( g_str_has_prefix ( entry, checked_prefix ) ) {
return;
}
}
int found = 0; int found = 0;
unsigned int curr = 0; unsigned int curr = 0;
unsigned int length = 0; unsigned int length = 0;

View File

@ -141,6 +141,8 @@ static XrmOption xrmOptions[] = {
"DRUN format string. (Supports: generic,name,comment,exec,categories)", CONFIG_DEFAULT }, "DRUN format string. (Supports: generic,name,comment,exec,categories)", CONFIG_DEFAULT },
{ xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL, { xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL,
"Disable history in run/ssh", CONFIG_DEFAULT }, "Disable history in run/ssh", CONFIG_DEFAULT },
{ xrm_String, "ignored-prefixes", { .str = &config.ignored_prefixes }, NULL,
"Programs ignored for history", CONFIG_DEFAULT },
{ xrm_Boolean, "sort", { .num = &config.sort }, NULL, { xrm_Boolean, "sort", { .num = &config.sort }, NULL,
"Use sorting", CONFIG_DEFAULT }, "Use sorting", CONFIG_DEFAULT },
{ xrm_String, "sorting-method", { .str = &config.sorting_method }, NULL, { xrm_String, "sorting-method", { .str = &config.sorting_method }, NULL,