Date: Sun, 20 Feb 2022 13:23:47 +0000 From: =?UTF-8?Q?Xianwen_Chen_=28=E9=99=88=E8=B4=A4=E6=96=87=29?= <xchen@live.no> To: freebsd-questions@freebsd.org Subject: Automatic save of .history in .cshrc Message-ID: <AM6PR10MB232898EA2C4FADB276703EB4BB399@AM6PR10MB2328.EURPRD10.PROD.OUTLOOK.COM>
next in thread | raw e-mail | index | archive | help
--=_6e2d251f6a92335d8d027addcd4e1692 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Hi! I set the history to 8000: set history = 8000 set savehist = (8000 merge) I would like to move the first 4000 lines of .history to a directory. Let's call the directory ~/.history_archive. The reason that I don't want to move all the contents of .history, is because I would like to have the recent history for auto completion. I found out a csh script to partly do what I envisioned, from https://forums.freebsd.org/threads/csh-history-file.65582/: set HIST="~/.history" if (`wc --libxo text -l ${HIST} | cut -d '/' -f1` == 2000) then mv ${HIST} ${HIST}.old touch ${HIST} && chmod 600 ${HIST} endif Would the following csh code be correct? Because csh only saves / appends to ~/.history when I log out, I use greater or equal to as the the condition. When there are 6000 lines or more, I split the .history files into two. The first one has 4000 lines, which will be moved to ~/.history_archive, with a file name that contains time information. The other file is moved to be the current ~/.history. set HIST="~/.history" if (`wc --libxo text -l ${HIST} | cut -d '/' -f1` >= 6000) then split -l 4000 ${HIST} mv xaa ~/.history_archive/history-`date +"%Y-%m-%d-%H-%M" ` mv xab ${HIST} chmod 600 ${HIST} endif Cheers, Xianwen --=_6e2d251f6a92335d8d027addcd4e1692 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8 <html><head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8"></= head><body style=3D"font-size: 10pt; font-family: Verdana,Geneva,sans-serif= "> <p>Hi!</p> <p>I set the history to 8000:</p> <p> set history =3D 8000<br> set savehist =3D (8000 merge)</p> <p>I would like to move the first 4000 lines of .history to a directory. Le= t's call the directory ~/.history_archive.</p> <p>The reason that I don't want to move all the contents of .history, is be= cause I would like to have the recent history for auto completion.</p> <p>I found out a csh script to partly do what I envisioned, from <a href=3D= "https://forums.freebsd.org/threads/csh-history-file.65582/">https://forums= .freebsd.org/threads/csh-history-file.65582/</a>:</p> <p> set HIST=3D"~/.history"</p> <p> if (`wc --libxo text -l ${HIST} | cut -d '/' -f1` =3D=3D 2000) th= en<br> mv ${HIST} ${HIST}.old<br> &= nbsp; touch ${HIST} && chmod 600 ${HIST}<br> endif</p> <p>Would the following csh code be correct? Because csh only saves / append= s to ~/.history when I log out, I use greater or equal to as the the condit= ion. When there are 6000 lines or more, I split the .history files into two= . The first one has 4000 lines, which will be moved to ~/.history_archive, = with a file name that contains time information. The other file is moved to= be the current ~/.history.</p> <p> set HIST=3D"~/.history"</p> <p> if (`wc --libxo text -l ${HIST} | cut -d '/' -f1` >=3D 6000) t= hen</p> <p> split -l 4000 ${HIST}</p> <p> mv xaa ~/.history_archive/history-`date +&qu= ot;%Y-%m-%d-%H-%M" `</p> <p> mv xab ${HIST}</p> <p> chmod 600 ${HIST}<br> endif</p> <p>Cheers,</p> <p>Xianwen</p> </body></html> --=_6e2d251f6a92335d8d027addcd4e1692--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AM6PR10MB232898EA2C4FADB276703EB4BB399>