diff --git a/config/config.c b/config/config.c index 8e2bc62a..56053b04 100644 --- a/config/config.c +++ b/config/config.c @@ -91,6 +91,8 @@ Settings config = { .fixed_num_lines = TRUE, /** Do not use history */ .disable_history = FALSE, + /** Programs ignored for history */ + .ignored_prefixes = "", /** Sort the displayed list */ .sort = FALSE, /** Use levenshtein sorting when matching */ diff --git a/include/history.h b/include/history.h index 114f068f..c20c5910 100644 --- a/include/history.h +++ b/include/history.h @@ -36,6 +36,7 @@ * * This uses the following options from the #config object: * * #Settings::disable_history + * * #Settings::ignored_prefixes * * @{ */ diff --git a/include/settings.h b/include/settings.h index db7f4f7d..acd0f307 100644 --- a/include/settings.h +++ b/include/settings.h @@ -108,6 +108,8 @@ typedef struct unsigned int fixed_num_lines; /** Do not use history */ unsigned int disable_history; + /** Programs ignored for history */ + char * ignored_prefixes; /** Toggle to enable sorting. */ unsigned int sort; /** Sorting method. */ diff --git a/source/history.c b/source/history.c index 64f73205..c17fe040 100644 --- a/source/history.c +++ b/source/history.c @@ -180,6 +180,20 @@ void history_set ( const char *filename, const char *entry ) if ( config.disable_history ) { 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; unsigned int curr = 0; unsigned int length = 0; diff --git a/source/xrmoptions.c b/source/xrmoptions.c index cb05a9b4..d7bae743 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -141,6 +141,8 @@ static XrmOption xrmOptions[] = { "DRUN format string. (Supports: generic,name,comment,exec,categories)", CONFIG_DEFAULT }, { xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL, "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, "Use sorting", CONFIG_DEFAULT }, { xrm_String, "sorting-method", { .str = &config.sorting_method }, NULL,