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 c6a796cd94b2c96f5259e613c582b1a80eadd0c2

MD - youtube video; log metrics test.
Author: Martin Dvorak
Author date (UTC): 2014-01-24 07:31
Committer name: Martin Dvorak
Committer date (UTC): 2014-01-24 07:31
Parent(s): 762fd77c4d3f953bc2613d066620f230d82c4308
Signing key:
Tree: 22df7dd3286625f5746540446ef73078a83075b6
File Lines added Lines deleted
README.md 1 1
src/hstr.c 2 0
src/hstr_history.c 2 1
tests/_ranking 0 0
tests/src/test_hashset.c 11 7
tests/src/test_ranking.c 19 0
tests/test_ranking.sh 1 0
File README.md changed (mode: 100644) (index 17bf921..3c6fb3a)
1 1 hstr hstr
2 2 ==== ====
3 3
4 BASH History Suggest Box - [http://www.youtube.com/watch?v=QYP4PlPvzT0](http://www.youtube.com/watch?v=QYP4PlPvzT0)
4 BASH History Suggest Box - [http://www.youtube.com/watch?v=sPF29NyXe2U](http://www.youtube.com/watch?v=sPF29NyXe2U)
5 5
6 6
7 7 DESCRIPTION DESCRIPTION
File src/hstr.c changed (mode: 100644) (index f88d4d7..7175f82)
... ... void selection_loop(HistoryItems *history)
377 377 case K_CTRL_T: case K_CTRL_T:
378 378 caseSensitive=!caseSensitive; caseSensitive=!caseSensitive;
379 379 result=print_selection(maxHistoryItems, prefix, history); result=print_selection(maxHistoryItems, prefix, history);
380 // TODO render selected line (or reset and move to prompt)
380 381 print_history_label(history); print_history_label(history);
381 382 break; break;
382 383 case K_CTRL_H: case K_CTRL_H:
383 384 defaultOrder=!defaultOrder; defaultOrder=!defaultOrder;
384 385 result=print_selection(maxHistoryItems, prefix, history); result=print_selection(maxHistoryItems, prefix, history);
386 // TODO render selected line (or reset and move to prompt)
385 387 print_history_label(history); print_history_label(history);
386 388 break; break;
387 389 case K_CTRL_X: case K_CTRL_X:
File src/hstr_history.c changed (mode: 100644) (index d592d61..e7baf39)
... ... static const char *commandBlacklist[] = {
35 35 #endif #endif
36 36
37 37 unsigned history_ranking_function(unsigned rank, int newOccurenceOrder, size_t length) { unsigned history_ranking_function(unsigned rank, int newOccurenceOrder, size_t length) {
38 long metrics=rank+newOccurenceOrder/10+length;
38 //long metrics=rank+newOccurenceOrder/10+length;
39 long metrics=rank+(log(newOccurenceOrder)*10.0)+length;
39 40 assert(metrics<UINT_MAX); assert(metrics<UINT_MAX);
40 41 return metrics; return metrics;
41 42 } }
File tests/_ranking added (mode: 100755) (index 0000000..6e660b6)
File tests/src/test_hashset.c changed (mode: 100644) (index eade8b2..7ab3998)
7 7
8 8 #include "../src/include/hashset.h" #include "../src/include/hashset.h"
9 9
10 int main(int argc, char *argv[])
11 {
12 const char *commandBlacklist[] = {"ls", "pwd", "cd", "hh", "mc"};
10 void testBlacklist() {
11 const char* commandBlacklist[] = { };
13 12 HashSet blacklist; HashSet blacklist;
14 13 int i; int i;
15 14 hashset_init(&blacklist); hashset_init(&blacklist);
16 for(i=0; i<5; i++) {
15 for (i = 0; i < 5; i++) {
17 16 hashset_add(&blacklist, commandBlacklist[i]); hashset_add(&blacklist, commandBlacklist[i]);
18 17 } }
19
20 for(i=0; i<5; i++) {
21 printf("match %d\n", hashset_contains(&blacklist, strdup(commandBlacklist[i])));
18 for (i = 0; i < 5; i++) {
19 printf("match %d\n",
20 hashset_contains(&blacklist, strdup(commandBlacklist[i])));
22 21 } }
23 22 } }
24 23
24 int main(int argc, char *argv[])
25 {
26 testBlacklist();
27 }
28
File tests/src/test_ranking.c added (mode: 100644) (index 0000000..d93c528)
1 /* Test
2 */
3
4 #include <stdio.h>
5 #include <math.h>
6
7 void testLog() {
8 const int HISTORY_SIZE=2000;
9 int i;
10 for(i=0; i<HISTORY_SIZE; i++) {
11 printf("\n%d # l: %f # l10: %f # l2: %f",i,log(i), log10(i), log2(i));
12 }
13 }
14
15 int main(int argc, char *argv[])
16 {
17 testLog();
18 }
19
File tests/test_ranking.sh added (mode: 100755) (index 0000000..6543b3d)
1 gcc ./src/test_ranking.c -lm -o _ranking
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