Home I taught Google Bard how to use ZSH history expansion
Post
Cancel

I taught Google Bard how to use ZSH history expansion

Despite my usual concerns and paranoia about privacy when it comes to using Google Products, I’ve been using Google Bard as a full replacement for standard search engines for a while now, and I have to be honest, it works, it improves my productivity and it’s fun to use.

Today I discovered something amazing and scary at the same time: talking with Google Bard is a two-way communication and if you correct it, Bard will remember your correction, learn from it and provide the correct answer next time.

I was looking for a way to re-use the same arguments of a previous command to a new one in ZSH and I asked Bard:

I asked Bard how to re-use arguments in ZSH

I tried and it didn’t work, so I told him:

I told Bard it didn't work

Bard was very sure about his answer. I was in doubt I didn’t use the right prompt (yeah, I know, Bard didn’t understand and I felt I was the one wrong, that tells a lot about my personality and how much we trust Google) so I tried to verify we were talking about the same thing with an example:

I verified it Bard understood

Yes, Bard understood, but the provided solution simply didn’t work. So, I fell back to the dear old search engine (Brave in my case) and I found this wonderful page about ZSH history expansion.

The solution to re-use the same arguments for a different command in ZSH is to use the ‘!’ modifier. Hence, if my previous command was “cat ./text.txt”, in order to open ‘./text.txt’ in VS Code, I can run “code !” and ZSH will expand the command to “code ./text.txt”.

I was going to simply annotate it in my notes, but then I thought: “Hey, why don’t I tell Bard about it?”. So I did:

I corrected Google Bard

What I nice guy is this Bard!

But now the interesting part, I wonder if it learnt from my correction, let me ask again the same question:

Google Bard learnt from me

OMG, it did! I wonder whether it’ll apply what it learnt also if another user asked.

This post is licensed under CC BY 4.0 by the author.

A Docker-based development environment for Jekyll

-

Comments powered by Disqus.