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 fa65c1fd31bea76d483f949da43ce945175040d9

Moving curses code to a separate module to make main cleaner.
Author: Martin Dvorak
Author date (UTC): 2014-01-25 12:40
Committer name: Martin Dvorak
Committer date (UTC): 2014-01-25 12:40
Parent(s): f14091ed4405cd2e0460ec9751840b8aaf810d77
Signing key:
Tree: d0314ef98e0658f67865283ea2c1b4cff94d300e
File Lines added Lines deleted
src/hstr_curses.c 24 0
src/hstr_history.c 2 2
src/include/hstr_curses.h 22 0
src/include/hstr_history.h 1 1
File src/hstr_curses.c added (mode: 100644) (index 0000000..700f74c)
1 /*
2 ============================================================================
3 Name : hstr_curses.c
4 Author : martin.dvorak@midforger.com
5 Copyright : Apache 2.0
6 Description : Curses utilities
7 ============================================================================
8 */
9
10 #include "include/hstr_curses.h"
11
12 static bool terminalHasColors=FALSE;
13
14 void color_start()
15 {
16 terminalHasColors=has_colors();
17 if(terminalHasColors) {
18 start_color();
19 }
20 }
21
22 bool terminal_has_colors() {
23 return terminalHasColors;
24 }
File src/hstr_history.c changed (mode: 100644) (index e7baf39..eb2907b)
... ... char *get_history_file_name()
46 46 char *historyFile=getenv(ENV_VAR_HISTFILE); char *historyFile=getenv(ENV_VAR_HISTFILE);
47 47 if(!historyFile || strlen(historyFile)==0) { if(!historyFile || strlen(historyFile)==0) {
48 48 char *home = getenv(ENV_VAR_HOME); char *home = getenv(ENV_VAR_HOME);
49 historyFile = malloc(strlen(home) + 1 + strlen(FILE_HISTORY) + 1);
50 strcat(strcat(strcpy(historyFile, home), "/"), FILE_HISTORY);
49 historyFile = malloc(strlen(home) + 1 + strlen(DEFAULT_HISTORY_FILE) + 1);
50 strcat(strcat(strcpy(historyFile, home), "/"), DEFAULT_HISTORY_FILE);
51 51 } }
52 52 return historyFile; return historyFile;
53 53 } }
File src/include/hstr_curses.h added (mode: 100644) (index 0000000..aefff03)
1 /*
2 ============================================================================
3 Name : hstr_curses.h
4 Author : martin.dvorak@midforger.com
5 Copyright : Apache 2.0
6 Description : Curses helpers
7 ============================================================================
8 */
9
10 #ifndef _HSTR_CURSES_H
11 #define _HSTR_CURSES_H
12
13 #include <curses.h>
14
15 #define color_attr_on(C) if(terminal_has_colors()) { attron(C); }
16 #define color_attr_off(C) if(terminal_has_colors()) { attroff(C); }
17 #define color_init_pair(X, Y, Z) if(terminal_has_colors()) { init_pair(X, Y, Z); }
18
19 bool terminal_has_colors();
20 void color_start();
21
22 #endif
File src/include/hstr_history.h changed (mode: 100644) (index 7798bbd..0c7ef55)
25 25 #define ENV_VAR_HOME "HOME" #define ENV_VAR_HOME "HOME"
26 26 #define ENV_VAR_HISTFILE "HISTFILE" #define ENV_VAR_HISTFILE "HISTFILE"
27 27
28 #define FILE_HISTORY ".bash_history"
28 #define DEFAULT_HISTORY_FILE ".bash_history"
29 29
30 30 typedef struct { typedef struct {
31 31 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