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 0f32fe0c657da22ef6215700dfbf3b2f52f87a63

Sync commit before branch switch.
Author: Martin Dvorak
Author date (UTC): 2014-03-27 13:16
Committer name: Martin Dvorak
Committer date (UTC): 2014-03-27 13:16
Parent(s): 1aab89187f1e15a6ba39275cc17f1ec80fd42bd6
Signing key:
Tree: 5e362ba0ba66687fee80bbab79b7ca04668033fb
File Lines added Lines deleted
src/hstr_favorites.c 36 0
src/include/hstr_favorites.h 4 1
src/include/hstr_history.h 1 3
File src/hstr_favorites.c changed (mode: 100644) (index 905ee57..83a2695)
8 8 */ */
9 9
10 10 #include <stdbool.h> #include <stdbool.h>
11 #include <stdio.h>
11 12 #include <string.h> #include <string.h>
13 #include <unistd.h>
12 14 #include "include/hstr_favorites.h" #include "include/hstr_favorites.h"
13 15
14 16 #define FAVORITE_SEGMENT_SIZE 10 #define FAVORITE_SEGMENT_SIZE 10
 
... ... void favorites_load(FavoriteItems *favorites)
28 30 strcpy(favorites->items[0],"a"); strcpy(favorites->items[0],"a");
29 31 favorites->items[1]=malloc(2); favorites->items[1]=malloc(2);
30 32 strcpy(favorites->items[1],"b"); strcpy(favorites->items[1],"b");
33
34 lazy loading (boolean indicator to FavoriteItems)
35
36 // TODO load from file
37
38 char *home = getenv(ENV_VAR_HOME);
39 char *fileName=(char*)malloc(strlen(home)+1+strlen(FILE_HH_RC)+1);
40 strcpy(fileName,home);
41 strcat(fileName,"/");
42 strcat(fileName,FILE_HH_RC);
43
44 char *file_contents=NULL;
45 if(access(fileName, F_OK) != -1) {
46 long input_file_size;
47
48 FILE *input_file = fopen(fileName, "rb");
49 fseek(input_file, 0, SEEK_END);
50 input_file_size = ftell(input_file);
51 rewind(input_file);
52 file_contents = malloc((input_file_size + 1) * (sizeof(char)));
53 if(fread(file_contents, sizeof(char), input_file_size, input_file)==-1) {
54 exit(EXIT_FAILURE);
55 }
56 fclose(input_file);
57 file_contents[input_file_size] = 0;
58 } else {
59 fprintf(stderr,"\nHistory file not found: %s\n",fileName);
60 }
61
62 if(file_contents) {
63 split & process & initilize favorites
64 }
31 65 } }
32 66
33 67 void favorites_add(FavoriteItems *favorites, char *newFavorite) void favorites_add(FavoriteItems *favorites, char *newFavorite)
 
... ... void favorites_remove(FavoriteItems *favorites, char *almostDead)
69 103
70 104 void favorites_save(FavoriteItems *favorites) void favorites_save(FavoriteItems *favorites)
71 105 { {
106 create/update history file
107
72 108 } }
73 109
74 110 void favorites_destroy(FavoriteItems *favorites) void favorites_destroy(FavoriteItems *favorites)
File src/include/hstr_favorites.h changed (mode: 100644) (index b134f9f..45d4e91)
12 12
13 13 #include <stdlib.h> #include <stdlib.h>
14 14
15 #define HH_RC_FILE ".hhrc"
15 #define ENV_VAR_USER "USER"
16 #define ENV_VAR_HOME "HOME"
17
18 #define FILE_HH_RC ".hhrc"
16 19
17 20 typedef struct { typedef struct {
18 21 char **items; char **items;
File src/include/hstr_history.h changed (mode: 100644) (index e38fb68..9f78b8b)
22 22 #include "hashset.h" #include "hashset.h"
23 23 #include "radixsort.h" #include "radixsort.h"
24 24
25 #define ENV_VAR_USER "USER"
26 #define ENV_VAR_HOME "HOME"
27 25 #define ENV_VAR_HISTFILE "HISTFILE" #define ENV_VAR_HISTFILE "HISTFILE"
28 26
29 #define DEFAULT_HISTORY_FILE ".bash_history"
27 #define FILE_DEFAULT_HISTORY ".bash_history"
30 28
31 29 typedef struct { typedef struct {
32 30 char **items; char **items;
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