File man/hh.1 changed (mode: 100644) (index f95010f..403ea83) |
... |
... |
hh allows removal of commands from history - for instance with a typo or with a |
15 |
15 |
.TP |
.TP |
16 |
16 |
\fB--show-configuration\fR |
\fB--show-configuration\fR |
17 |
17 |
Show configuration to be added to .bashrc |
Show configuration to be added to .bashrc |
|
18 |
|
.TP |
|
19 |
|
\fB--help\fR |
|
20 |
|
Show help |
18 |
21 |
.SH COMMANDS |
.SH COMMANDS |
19 |
22 |
.TP |
.TP |
20 |
23 |
\fBpattern\fR |
\fBpattern\fR |
|
... |
... |
Write changes to shell history and exit. |
52 |
55 |
.TP |
.TP |
53 |
56 |
\fBCtrl\-g\fR |
\fBCtrl\-g\fR |
54 |
57 |
Exit with empty prompt. |
Exit with empty prompt. |
55 |
|
.SH INSTALLATION |
|
56 |
|
Add the following lines to ~/.bashrc: |
|
|
58 |
|
.SH ENVIRONMENT VARIABLES |
|
59 |
|
\fBhh\fR defines the following environment variables: |
|
60 |
|
.TP |
|
61 |
|
\fBHH_CONFIG\fR |
|
62 |
|
Configuration options: \fBhicolor\fR to get more colors (default is monochromatic). |
|
63 |
|
.SH CONFIGURATION |
|
64 |
|
Optionally add the following lines to ~/.bashrc: |
57 |
65 |
.nf |
.nf |
58 |
66 |
.sp |
.sp |
|
67 |
|
export HH_CONFIG=hicolor # get more colors |
59 |
68 |
shopt -s histappend # append new history items to .bash_history |
shopt -s histappend # append new history items to .bash_history |
60 |
69 |
export HISTCONTROL=ignorespace # leading space hides commands from history |
export HISTCONTROL=ignorespace # leading space hides commands from history |
61 |
70 |
export HISTFILESIZE=10000 # increase history file size (default is 500) |
export HISTFILESIZE=10000 # increase history file size (default is 500) |
File src/hstr.c changed (mode: 100644) (index 0e29fac..e0aa26e) |
54 |
54 |
#define K_ENTER 10 |
#define K_ENTER 10 |
55 |
55 |
|
|
56 |
56 |
#define HH_COLOR_NORMAL 1 |
#define HH_COLOR_NORMAL 1 |
57 |
|
#define HH_COLOR_HIGHROW 2 |
|
|
57 |
|
#define HH_COLOR_HIROW 2 |
58 |
58 |
#define HH_COLOR_PROMPT 3 |
#define HH_COLOR_PROMPT 3 |
59 |
59 |
#define HH_COLOR_DELETE 4 |
#define HH_COLOR_DELETE 4 |
60 |
60 |
|
|
|
61 |
|
#define ENV_VAR_HH_CONFIG "HH_CONFIG" |
|
62 |
|
|
61 |
63 |
#ifdef DEBUG_KEYS |
#ifdef DEBUG_KEYS |
62 |
64 |
#define LOGKEYS(Y,KEY) mvprintw(Y, 0, "Key: '%3d' / Char: '%c'", KEY, KEY); clrtoeol() |
#define LOGKEYS(Y,KEY) mvprintw(Y, 0, "Key: '%3d' / Char: '%c'", KEY, KEY); clrtoeol() |
63 |
65 |
#else |
#else |
|
... |
... |
static bool hicolor=FALSE; |
102 |
104 |
static char screenLine[1000]; |
static char screenLine[1000]; |
103 |
105 |
static char cmdline[CMDLINE_LNG]; |
static char cmdline[CMDLINE_LNG]; |
104 |
106 |
|
|
|
107 |
|
void get_env_configuration() |
|
108 |
|
{ |
|
109 |
|
char *hhconfig=getenv(ENV_VAR_HH_CONFIG); |
|
110 |
|
if(hhconfig && strlen(hhconfig)>0) { |
|
111 |
|
if(strstr(hhconfig,"hicolor")) { |
|
112 |
|
hicolor=TRUE; |
|
113 |
|
} |
|
114 |
|
} |
|
115 |
|
} |
|
116 |
|
|
105 |
117 |
int print_prompt() |
int print_prompt() |
106 |
118 |
{ |
{ |
107 |
119 |
char *hostname = get_hostname(); |
char *hostname = get_hostname(); |
|
... |
... |
int print_prompt() |
109 |
121 |
int xoffset = 0; |
int xoffset = 0; |
110 |
122 |
|
|
111 |
123 |
if(hicolor) { |
if(hicolor) { |
112 |
|
color_attr_on(COLOR_PAIR(3)); |
|
|
124 |
|
color_attr_on(COLOR_PAIR(HH_COLOR_PROMPT)); |
|
125 |
|
color_attr_on(A_BOLD); |
113 |
126 |
} |
} |
114 |
127 |
mvprintw(Y_OFFSET_PROMPT, xoffset, "%s@%s$ ", user, hostname); |
mvprintw(Y_OFFSET_PROMPT, xoffset, "%s@%s$ ", user, hostname); |
115 |
128 |
if(hicolor) { |
if(hicolor) { |
116 |
|
color_attr_on(COLOR_PAIR(1)); |
|
|
129 |
|
color_attr_off(A_BOLD); |
|
130 |
|
color_attr_off(COLOR_PAIR(HH_COLOR_PROMPT)); |
117 |
131 |
} |
} |
118 |
132 |
refresh(); |
refresh(); |
119 |
133 |
|
|
|
... |
... |
void loop_to_select(HistoryItems *history) |
363 |
377 |
keypad(stdscr, TRUE); |
keypad(stdscr, TRUE); |
364 |
378 |
noecho(); |
noecho(); |
365 |
379 |
color_start(); |
color_start(); |
366 |
|
color_init_pair(1, COLOR_WHITE, COLOR_BLACK); |
|
|
380 |
|
color_init_pair(HH_COLOR_NORMAL, COLOR_WHITE, COLOR_BLACK); |
367 |
381 |
if(hicolor) { |
if(hicolor) { |
368 |
|
color_init_pair(2, COLOR_WHITE, COLOR_GREEN); |
|
369 |
|
color_init_pair(3, COLOR_CYAN, COLOR_BLACK); |
|
370 |
|
color_init_pair(4, COLOR_WHITE, COLOR_RED); |
|
|
382 |
|
color_init_pair(HH_COLOR_HIROW, COLOR_WHITE, COLOR_GREEN); |
|
383 |
|
color_init_pair(HH_COLOR_PROMPT, COLOR_BLUE, COLOR_BLACK); |
|
384 |
|
color_init_pair(HH_COLOR_DELETE, COLOR_WHITE, COLOR_RED); |
371 |
385 |
} |
} |
372 |
|
color_attr_on(COLOR_PAIR(1)); |
|
373 |
386 |
|
|
374 |
|
print_history_label(history); |
|
|
387 |
|
color_attr_on(COLOR_PAIR(HH_COLOR_NORMAL)); |
375 |
388 |
print_help_label(); |
print_help_label(); |
|
389 |
|
print_history_label(history); |
376 |
390 |
print_selection(get_max_history_items(stdscr), NULL, history); |
print_selection(get_max_history_items(stdscr), NULL, history); |
|
391 |
|
color_attr_off(COLOR_PAIR(HH_COLOR_NORMAL)); |
377 |
392 |
|
|
378 |
|
color_attr_off(COLOR_PAIR(1)); |
|
379 |
|
|
|
380 |
|
bool done=FALSE, skip=TRUE, executeResult=FALSE, lowercase=TRUE; |
|
|
393 |
|
bool done=FALSE, skip=TRUE, executeResult=FALSE, lowercase=TRUE, justDeleted=FALSE; |
381 |
394 |
int basex=print_prompt(stdscr); |
int basex=print_prompt(stdscr); |
382 |
395 |
int x=basex, y=0, c, cursorX=0, cursorY=0, maxHistoryItems, deleteOccurences; |
int x=basex, y=0, c, cursorX=0, cursorY=0, maxHistoryItems, deleteOccurences; |
383 |
396 |
int width=getmaxx(stdscr); |
int width=getmaxx(stdscr); |
|
... |
... |
void loop_to_select(HistoryItems *history) |
406 |
419 |
continue; |
continue; |
407 |
420 |
} |
} |
408 |
421 |
|
|
|
422 |
|
if(justDeleted) { |
|
423 |
|
print_help_label(); |
|
424 |
|
justDeleted=FALSE; |
|
425 |
|
} |
|
426 |
|
|
409 |
427 |
switch (c) { |
switch (c) { |
410 |
428 |
case KEY_DC: |
case KEY_DC: |
411 |
429 |
if(selectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) { |
if(selectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) { |
|
... |
... |
void loop_to_select(HistoryItems *history) |
417 |
435 |
result=print_selection(maxHistoryItems, pattern, history); |
result=print_selection(maxHistoryItems, pattern, history); |
418 |
436 |
print_cmd_deleted_label(msg, deleteOccurences); |
print_cmd_deleted_label(msg, deleteOccurences); |
419 |
437 |
move(y, basex+strlen(pattern)); |
move(y, basex+strlen(pattern)); |
|
438 |
|
justDeleted=TRUE; |
420 |
439 |
} |
} |
421 |
440 |
print_history_label(history); |
print_history_label(history); |
422 |
441 |
break; |
break; |
|
... |
... |
void hstr() |
566 |
585 |
HistoryItems *history=get_prioritized_history(); |
HistoryItems *history=get_prioritized_history(); |
567 |
586 |
if(history) { |
if(history) { |
568 |
587 |
history_mgmt_open(); |
history_mgmt_open(); |
|
588 |
|
get_env_configuration(); |
569 |
589 |
loop_to_select(history); |
loop_to_select(history); |
570 |
590 |
hstr_on_exit(); |
hstr_on_exit(); |
571 |
591 |
} else { |
} else { |