* Re: Memory usage of history?
[not found] ` <CAH+w=7YQz6iaJf0k=OkX2bQSL26ohU3wLRVYgki_Z6jLOYpzSw__6555.25048864565$1466819341$gmane$org@mail.gmail.com>
@ 2016-06-25 17:43 ` Christian Neukirchen
0 siblings, 0 replies; only message in thread
From: Christian Neukirchen @ 2016-06-25 17:43 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer <schaefer@brasslantern.com> writes:
> On Fri, Jun 24, 2016 at 6:47 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
>>
>> (A colleague
>> says his zshs use 200 MB memory each with a history size of a
>> million lines).
>
> To expand on Eric's answer, zsh reads the entire $HISTFILE and retains
> the last $HISTSIZE entries. So a large $HISTFILE also slows down
> startup, even if it doesn't consume lots of memory.
>
> I can't imagine anyone having a million useful lines of history. A
> few tens of thousands at most.
I use the following functions to create an additional, write-only,
daily history, and a helper to search it:
# Keep an archive of all commands typed.
# Initialize using:
# cat /data/dump/juno/2015<->/home/chris/.zsh_history | sort -u | grep '^:' |
# gawk -F: '{print $0 >> "chris@juno-" strftime("%Y-%m-%d", $2)}'
# 04sep2015 +chris+
mkdir -p ~/.zarchive
zshaddhistory() {
local words=( ${(z)1} )
local w1=$words[1]
(( $+aliases[$w1] )) && w1=$aliases[$w1]
if [[ -n $1 && $1 != $'\n' && $w1 != " "* ]]; then
printf ': %s:0;%s' ${(%):-%D{%s}} "$1" >> \
~/.zarchive/${(%):-%n@%m-%D{%Y-%m-%d}}
fi
}
# za WORDS... - search .zarchive for WORDS
za() {
grep -a -r -e "${(j:.*:)@}" ~/.zarchive |
sed 's/[ \t]*$//' |
sort -r | sort -t';' -k2 -u | sort |
sed $'s,^[^:]*/,,; s,::[^;]*;,\u00A0\u00A0,'
}
alias za=' za'
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-06-25 18:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20160624134706.GA22704@linux.vnet.ibm.com>
[not found] ` <CAH+w=7YQz6iaJf0k=OkX2bQSL26ohU3wLRVYgki_Z6jLOYpzSw__6555.25048864565$1466819341$gmane$org@mail.gmail.com>
2016-06-25 17:43 ` Memory usage of history? Christian Neukirchen
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).