summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoav <gergesh@gmail.com>2018-12-31 01:35:00 +0200
committerQuentin Glidic <sardemff7+github@sardemff7.net>2018-12-31 00:35:00 +0100
commit238648b5b2267724e2cf7d0c238fca9d983b0c6a (patch)
tree27359ce471e3905e4714049a53d42a1449589a81
parentaacb570850dced80b3490f85037e7a9beaabdc4f (diff)
Add history ignore (#846)
-rw-r--r--config/config.c2
-rw-r--r--include/history.h1
-rw-r--r--include/settings.h2
-rw-r--r--source/history.c14
-rw-r--r--source/xrmoptions.c2
5 files changed, 21 insertions, 0 deletions
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,