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 74ab6be36bd091efa92aebe97220d12096ce0994

Fixed #200 by detection of Zsh timestamps in history and trimming it.
Author: Martin Dvorak
Author date (UTC): 2017-01-21 19:24
Committer name: Martin Dvorak
Committer date (UTC): 2017-01-21 19:27
Parent(s): 367e074a703fb29d5af173ef6977ba516bc75718
Signing key:
Tree: cf96ba30242d39e866039442981ee74ff164ce22
File Lines added Lines deleted
src/hstr_history.c 23 14
File src/hstr_history.c changed (mode: 100644) (index 341a7fe..1e01f35)
... ... int history_mgmt_remove_from_system_history(char *cmd)
225 225 HISTORY_STATE *historyState=history_get_history_state(); HISTORY_STATE *historyState=history_get_history_state();
226 226
227 227 // TODO refactor this code to have this in source exactly once // TODO refactor this code to have this in source exactly once
228 regex_t regexp;
228 regex_t tsRegexp;
229 regex_t zshRegexp;
229 230 // HISTTIMEFORMAT defined > ^#1234567890$ // HISTTIMEFORMAT defined > ^#1234567890$
230 231 const char *histtimeformatTimestamp = "^#[[:digit:]]\\{10,\\}$"; const char *histtimeformatTimestamp = "^#[[:digit:]]\\{10,\\}$";
231 regexp_compile(&regexp, histtimeformatTimestamp);
232 regexp_compile(&tsRegexp, histtimeformatTimestamp);
233
234 const char *zshTimestamp = "^: [[:digit:]]\\{10,\\}:[[:digit:]];.*";
235 regexp_compile(&zshRegexp, zshTimestamp);
232 236
233 237 while(offset>=0) { while(offset>=0) {
234 238 l=historyState->entries[offset]->line; l=historyState->entries[offset]->line;
235 if(offset<historyState->length && !strcmp(cmd, l)) {
236 occurences++;
237 free_history_entry(remove_history(offset));
238 if(offset>0) {
239 l=historyState->entries[offset-1]->line;
240 if(l && strlen(l)) {
241 if(!regexp_match(&regexp, l)) {
242 // TODO check that this delete doesn't cause mismatch of searched cmd to be deleted
243 free_history_entry(remove_history(offset-1));
244 }
245 }
246 }
239 if(offset<historyState->length) {
240 if(!regexp_match(&zshRegexp, l)) {
241 l=l+15; //: 1485023566:0;whoami
242 }
243 if(!strcmp(cmd, l)) {
244 occurences++;
245 free_history_entry(remove_history(offset));
246 if(offset>0) {
247 l=historyState->entries[offset-1]->line;
248 if(l && strlen(l)) {
249 if(!regexp_match(&tsRegexp, l)) {
250 // TODO check that this delete doesn't cause mismatch of searched cmd to be deleted
251 free_history_entry(remove_history(offset-1));
252 }
253 }
254 }
255 }
247 256 } }
248 257 offset=history_search_pos(cmd, 0, ++offset); offset=history_search_pos(cmd, 0, ++offset);
249 258 } }
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