File README.md changed (mode: 100644) (index 52722fc..0390b32) |
... |
... |
https://github.com/dvorka/hstr/releases |
17 |
17 |
|
|
18 |
18 |
INSTALLATION |
INSTALLATION |
19 |
19 |
------------ |
------------ |
20 |
|
* bind `hh` to a key and/or add it to $PATH |
|
21 |
|
* bind `hh` to a BASH key by adding a line to your `.bashrc`, e.g. Ctrl-R: |
|
|
20 |
|
* add |
|
21 |
|
|
|
22 |
|
`shopt -s histappend` |
|
23 |
|
`export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"` |
|
24 |
|
|
|
25 |
|
at the end of `.bashrc` in order to ensure that BASH history of commands |
|
26 |
|
will be kept in sync with filesystem. |
|
27 |
|
* bind `hh` to a BASH key by adding a line to `.bashrc`, e.g. Ctrl-R: |
22 |
28 |
|
|
23 |
29 |
`bind '"\C-r": "\C-k\C-uhh\C-j"'` |
`bind '"\C-r": "\C-k\C-uhh\C-j"'` |
24 |
30 |
|
|
|
... |
... |
INSTALLATION |
32 |
38 |
|
|
33 |
39 |
To determine the character sequence emitted by a pressed key in terminal, |
To determine the character sequence emitted by a pressed key in terminal, |
34 |
40 |
type CTRL-v and then press the key. For example, F12 gives `^[[24~`. |
type CTRL-v and then press the key. For example, F12 gives `^[[24~`. |
35 |
|
Replace the `^[` with `\e`. To clear the line first, add `\C-k \C-u` in front of |
|
36 |
|
the actual command. Check your current bindings using: |
|
|
41 |
|
Replace the `^[` with `\e`. To clear the line first, add `\C-k \C-u` in |
|
42 |
|
front of the actual command. Check your current bindings using: |
37 |
43 |
|
|
38 |
44 |
`bind -S` |
`bind -S` |
39 |
45 |
|
|
File src/hstr_history.c changed (mode: 100644) (index cde4a97..1d57aa3) |
... |
... |
void free_prioritized_history() { |
115 |
115 |
// TODO free(prioritizedHistory); |
// TODO free(prioritizedHistory); |
116 |
116 |
} |
} |
117 |
117 |
|
|
118 |
|
void flush_history() { |
|
119 |
|
const char *filename = "history"; |
|
120 |
|
char *const args[1] = {"-a"}; |
|
121 |
|
execvp(filename, args); |
|
122 |
|
} |
|
123 |
|
|
|
124 |
118 |
HistoryItems *get_history_items() { |
HistoryItems *get_history_items() { |
125 |
119 |
history=(HistoryItems *)malloc(sizeof(HistoryItems)); |
history=(HistoryItems *)malloc(sizeof(HistoryItems)); |
126 |
120 |
|
|
127 |
|
flush_history(); |
|
128 |
121 |
using_history(); |
using_history(); |
129 |
122 |
|
|
130 |
123 |
char *historyFile = getenv(ENV_VAR_HISTFILE); |
char *historyFile = getenv(ENV_VAR_HISTFILE); |