bash history
Andrew Malcolmson
andzy-bYF1QM81rroS+FvcfC7Uqw at public.gmane.org
Tue Aug 19 00:08:03 UTC 2003
On 18 Aug 2003 00:37:13 -0400, "Tim Writer" <tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org> said:
> Lloyd D Budd <lloyd-fEEwcc3XMu8jODpR/OX0VQ at public.gmane.org> writes:
>
> > Hi,
> >
> > >From time to time I wonder how 'history' works, and what is the
> > mechanism for the many bash sessions making it into '.bash_history'?
> >
> > Today, I was reminded of my previous wondering as 'history' corrupted
> > my session's display -- 'reset' resolved.
> >
> > I find the most useful history related command to be:
> > [Ctrl]+r :: reverse incremental search
> >
> > I just now found HISTIGNORE.
> >
> > I am aware of bash-completion. It seems that one could do a lot more
> > with this thinking. Any smart history search/modification tools out
> > there?
>
> The Z shell (zsh) is much better at this sort of stuff than bash.
True. Zsh is the ultimate interactive shell. It's SHARE_HISTORY option
does the session history merging you're asking about.
In bash, '!' starts a history expansion: '!!' recalls the last command
line, '!$' recalls the final argument of the last command line, and
^foo^bar substitutes bar for foo in the previous line. See the bash man
page for more like this.
But Zsh does these and more: pressing TAB after entering one of these
sequences does the history expansion in the current line. Adding a :h
causes only the 'head' of a path (everything up to the final '/') to be
substituted, :t the 'tail' (filename), and :r the filename with any
suffix removed, e.g.
%~>less /usr/share/doc/thing/README
%~>cd !$:h
%/usr/share/doc/thing>
Since you asked about completion, zsh has special command-specific
completion features like:
cd <TAB> ==> lists directories
tar xzvf <TAB> ==> lists only files ending in .gz or .tgz
ls -<TAB> ==> a list of all possible argument to ls
dpkg -L <TAB> ==> a list of installed debian packages
scp localfile me-Ja3L+HSX0kI at public.gmane.org:<TAB> ==> Very cool: does remote path
completion!!
More info:
Linux Magazine Articles (see columns for May, June, July 2002)
http://www.linux-mag.com/depts/power.html
Other cool things in bash and zsh
http://www.jpeek.com/talks/ukuug_20000720/
Adam's Zsh & Shell pages
http://adamspiers.org/computing/zsh/
Zsh Fan Page
http://www.princeton.edu/~kmccarty/zsh.html
IBM Developer Works article.
http://www-106.ibm.com/developerworks/linux/library/l-z.html?open&l=335,t=gr,p=Z-Shell
Zsh User Guide (most comprehensive info)
http://zsh.sunsite.dk/Guide/zshguide.html
-------------------
Andrew Malcolmson
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list