xaizek / hstr (License: Apachev2) (since 2018-12-07)
Bash and Zsh shell history suggest box - easily view, navigate, search and manage your command history.
Commit 2795fb91953f7b58958eb1544b17caae4c74bcde

Added a warning for unknown HH_CONFIG items
Author: pknowles
Author date (UTC): 2017-06-05 03:04
Committer name: pknowles
Committer date (UTC): 2017-06-05 03:04
Parent(s): 24e1a1734304ee04156c7987e72b38f3cd657b76
Signing key:
Tree: 448ca236c6b965988763ebeb7644f0e468053f08
File Lines added Lines deleted
src/hstr.c 36 55
File src/hstr.c changed (mode: 100644) (index a1cc66a..c012729)
... ... void hstr_init()
296 296 hstr->interactive=true; hstr->interactive=true;
297 297 hstr->unique=true; hstr->unique=true;
298 298 hstr->showHelp = true; hstr->showHelp = true;
299 hstr->promptBottom = false;
299 300
300 301 hstr->theme=HH_THEME_MONO; hstr->theme=HH_THEME_MONO;
301 302 hstr->bigKeys=RADIX_BIG_KEYS_SKIP; hstr->bigKeys=RADIX_BIG_KEYS_SKIP;
 
... ... unsigned recalculate_max_history_items()
328 329
329 330 void hstr_get_env_configuration(Hstr *hstr) void hstr_get_env_configuration(Hstr *hstr)
330 331 { {
331 char *hstr_config=getenv(HH_ENV_VAR_CONFIG);
332 if(hstr_config && strlen(hstr_config)>0) {
333 if(strstr(hstr_config,HH_CONFIG_THEME_MONOCHROMATIC)) {
332 const char *hstr_config=getenv(HH_ENV_VAR_CONFIG);
333 if (!hstr_config || !strlen(hstr_config)) {
334 return;
335 }
336 size_t const len = strlen(hstr_config)+1;
337 char* config_items = malloc(len);
338 memcpy(config_items, hstr_config, len);
339 char* saveptr = config_items;
340 char* item;
341 while ((item = strtok_r(saveptr, ",", &saveptr)) != NULL) {
342 if(strcmp(item,HH_CONFIG_THEME_MONOCHROMATIC)==0) {
334 343 hstr->theme=HH_THEME_MONO; hstr->theme=HH_THEME_MONO;
335 } else {
336 if(strstr(hstr_config,HH_CONFIG_THEME_HICOLOR)) {
337 hstr->theme=HH_THEME_DARK;
338 }
339 }
340 if(strstr(hstr_config,HH_CONFIG_CASE)) {
344 } else if(strcmp(item,HH_CONFIG_THEME_HICOLOR)==0) {
345 hstr->theme=HH_THEME_DARK;
346 } else if(strcmp(item,HH_CONFIG_CASE)==0) {
341 347 hstr->caseSensitive=HH_CASE_SENSITIVE; hstr->caseSensitive=HH_CASE_SENSITIVE;
342 }
343 if(strstr(hstr_config,HH_CONFIG_REGEXP)) {
348 } else if(strcmp(item,HH_CONFIG_REGEXP)==0) {
344 349 hstr->historyMatch=HH_MATCH_REGEXP; hstr->historyMatch=HH_MATCH_REGEXP;
345 } else {
346 if(strstr(hstr_config,HH_CONFIG_SUBSTRING)) {
347 hstr->historyMatch=HH_MATCH_SUBSTRING;
348 } else {
349 if(strstr(hstr_config, HH_CONFIG_KEYWORDS)) {
350 hstr->historyMatch=HH_MATCH_KEYWORDS;
351 }
352 }
353 }
354 if(strstr(hstr_config,HH_CONFIG_SORTING)) {
350 } else if(strcmp(item,HH_CONFIG_SUBSTRING)==0) {
351 hstr->historyMatch=HH_MATCH_SUBSTRING;
352 } else if(strcmp(item, HH_CONFIG_KEYWORDS)==0) {
353 hstr->historyMatch=HH_MATCH_KEYWORDS;
354 } else if(strcmp(item,HH_CONFIG_SORTING)==0) {
355 355 hstr->historyView=HH_VIEW_HISTORY; hstr->historyView=HH_VIEW_HISTORY;
356 } else {
357 if(strstr(hstr_config,HH_CONFIG_FAVORITES)) {
358 hstr->historyView=HH_VIEW_FAVORITES;
359 }
360 }
361 if(strstr(hstr_config,HH_CONFIG_BIG_KEYS_EXIT)) {
356 } else if(strcmp(item,HH_CONFIG_FAVORITES)==0) {
357 hstr->historyView=HH_VIEW_FAVORITES;
358 } else if(strcmp(item,HH_CONFIG_BIG_KEYS_EXIT)==0) {
362 359 hstr->bigKeys=RADIX_BIG_KEYS_EXIT; hstr->bigKeys=RADIX_BIG_KEYS_EXIT;
363 } else {
364 if(strstr(hstr_config,HH_CONFIG_BIG_KEYS_FLOOR)) {
365 hstr->bigKeys=RADIX_BIG_KEYS_FLOOR;
366 } else {
367 hstr->bigKeys=RADIX_BIG_KEYS_SKIP;
368 }
369 }
370 if(strstr(hstr_config,HH_CONFIG_BLACKLIST)) {
360 } else if(strcmp(item,HH_CONFIG_BIG_KEYS_FLOOR)==0) {
361 hstr->bigKeys=RADIX_BIG_KEYS_FLOOR;
362 } else if(strcmp(item,HH_CONFIG_BLACKLIST)==0) {
371 363 hstr->blacklist.useFile=true; hstr->blacklist.useFile=true;
372 }
373
374 if(strstr(hstr_config,HH_CONFIG_DEBUG)) {
364 } else if(strcmp(item,HH_CONFIG_DEBUG)==0) {
375 365 hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG; hstr->debugLevel=HH_DEBUG_LEVEL_DEBUG;
376 } else {
377 if(strstr(hstr_config,HH_CONFIG_WARN)) {
378 hstr->debugLevel=HH_DEBUG_LEVEL_WARN;
379 }
380 }
381
382 if(strstr(hstr_config,HH_CONFIG_DUPLICATES)) {
366 } else if(strcmp(item,HH_CONFIG_WARN)==0) {
367 hstr->debugLevel=HH_DEBUG_LEVEL_WARN;
368 } else if(strcmp(item,HH_CONFIG_DUPLICATES)==0) {
383 369 hstr->unique=false; hstr->unique=false;
384 }
385
386 if(strstr(hstr_config,HH_CONFIG_PROMPT_BOTTOM)) {
370 } else if(strcmp(item,HH_CONFIG_PROMPT_BOTTOM)==0) {
387 371 hstr->promptBottom = true; hstr->promptBottom = true;
388 } else {
389 hstr->promptBottom = false;
390 }
391
392 if(strstr(hstr_config,HH_CONFIG_MINIMAL)) {
372 } else if(strcmp(item,HH_CONFIG_MINIMAL)==0) {
393 373 hstr->showHelp=false; hstr->showHelp=false;
374 } else {
375 fprintf(stderr, "WARNING: unknown item in %s: %s\n", HH_ENV_VAR_CONFIG, item);
394 376 } }
395
396 recalculate_max_history_items();
397 377 } }
378 free(config_items);
398 379 } }
399 380
400 381 int print_prompt() int print_prompt()
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/hstr

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/hstr

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master