<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: zsh</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/zsh.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2025-02-14T02:40:11+00:00</updated><author><name>Simon Willison</name></author><entry><title>How to add a directory to your PATH</title><link href="https://simonwillison.net/2025/Feb/14/how-to-add-a-directory-to-your-path/#atom-tag" rel="alternate"/><published>2025-02-14T02:40:11+00:00</published><updated>2025-02-14T02:40:11+00:00</updated><id>https://simonwillison.net/2025/Feb/14/how-to-add-a-directory-to-your-path/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://jvns.ca/blog/2025/02/13/how-to-add-a-directory-to-your-path/"&gt;How to add a directory to your PATH&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;em&gt;Classic&lt;/em&gt; Julia Evans piece here, answering a question which you might assume is obvious but very much isn't.&lt;/p&gt;
&lt;p&gt;Plenty of useful tips in here, plus the best explanation I've ever seen of the three different Bash configuration options:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Bash has three possible config files: &lt;code&gt;~/.bashrc&lt;/code&gt;, &lt;code&gt;~/.bash_profile&lt;/code&gt;, and &lt;code&gt;~/.profile&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you're not sure which one your system is set up to use, I'd recommend testing this way:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;add &lt;code&gt;echo hi there&lt;/code&gt; to your &lt;code&gt;~/.bashrc&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Restart your terminal&lt;/li&gt;
&lt;li&gt;If you see "hi there", that means &lt;code&gt;~/.bashrc&lt;/code&gt; is being used! Hooray!&lt;/li&gt;
&lt;li&gt;Otherwise remove it and try the same thing with &lt;code&gt;~/.bash_profile&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;You can also try &lt;code&gt;~/.profile&lt;/code&gt; if the first two options don't work.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;p&gt;This article also reminded me to &lt;a href="https://simonwillison.net/2024/Oct/15/path-tips-on-wizard-zines/"&gt;try which -a again&lt;/a&gt;, which gave me this confusing result for &lt;code&gt;datasette&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;% which -a datasette
/opt/homebrew/Caskroom/miniconda/base/bin/datasette
/Users/simon/.local/bin/datasette
/Users/simon/.local/bin/datasette
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Why is the second path in there twice? I figured out how to use &lt;code&gt;rg&lt;/code&gt; to search just the dot-files in my home directory:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rg local/bin -g '/.*' --max-depth 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And found that I have both a &lt;code&gt;.zshrc&lt;/code&gt; and &lt;code&gt;.zprofile&lt;/code&gt; file that are adding that to my path:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.zshrc.backup
4:export PATH="$PATH:/Users/simon/.local/bin"

.zprofile
5:export PATH="$PATH:/Users/simon/.local/bin"

.zshrc
7:export PATH="$PATH:/Users/simon/.local/bin"
&lt;/code&gt;&lt;/pre&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/bash"&gt;bash&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/julia-evans"&gt;julia-evans&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ripgrep"&gt;ripgrep&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/zsh"&gt;zsh&lt;/a&gt;&lt;/p&gt;



</summary><category term="bash"/><category term="julia-evans"/><category term="ripgrep"/><category term="zsh"/></entry><entry><title>q and qv zsh functions for asking questions of websites and YouTube videos with LLM</title><link href="https://simonwillison.net/2024/Dec/19/q-and-qv-zsh-functions/#atom-tag" rel="alternate"/><published>2024-12-19T15:42:34+00:00</published><updated>2024-12-19T15:42:34+00:00</updated><id>https://simonwillison.net/2024/Dec/19/q-and-qv-zsh-functions/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/davidgasquez/dotfiles/blob/bb9df4a369dbaef95ca0c35642de491c7dd41269/shell/zshrc#L50-L99"&gt;q and qv zsh functions for asking questions of websites and YouTube videos with LLM&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Spotted these in David Gasquez's &lt;code&gt;zshrc&lt;/code&gt; dotfiles: two shell functions that use my &lt;a href="https://llm.datasette.io/"&gt;LLM&lt;/a&gt; tool to answer questions about a website or YouTube video.&lt;/p&gt;
&lt;p&gt;Here's how to ask a question of a website:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;q https://simonwillison.net/ 'What has Simon written about recently?'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I got back:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Recently, Simon Willison has written about various topics including:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Building Python Tools&lt;/strong&gt; - Exploring one-shot applications using Claude and dependency management with &lt;code&gt;uv&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Modern Java Usage&lt;/strong&gt; - Discussing recent developments in Java that simplify coding.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GitHub Copilot Updates&lt;/strong&gt; - New free tier and features in GitHub Copilot for Vue and VS Code.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AI Engagement on Bluesky&lt;/strong&gt; - Investigating the use of bots to create artificially polite disagreements.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OpenAI WebRTC Audio&lt;/strong&gt; - Demonstrating a new API for real-time audio conversation with models.&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;
&lt;p&gt;It works by constructing a &lt;a href="https://simonwillison.net/2024/Jun/16/jina-ai-reader/"&gt;Jina Reader URL&lt;/a&gt; to convert that URL to Markdown, then piping that content into LLM along with the question.&lt;/p&gt;
&lt;p&gt;The YouTube one is even more fun:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;qv 'https://www.youtube.com/watch?v=uRuLgar5XZw' 'what does Simon say about open source?'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It said (about &lt;a href="https://www.youtube.com/watch?v=uRuLgar5XZw"&gt;this 72 minute video&lt;/a&gt;):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Simon emphasizes that open source has significantly increased productivity in software development. He points out that before open source, developers often had to recreate existing solutions or purchase proprietary software, which often limited customization. The availability of open source projects has made it easier to find and utilize existing code, which he believes is one of the primary reasons for more efficient software development today.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The secret sauce behind that one is the way it uses &lt;code&gt;yt-dlp&lt;/code&gt; to extract just the subtitles for the video:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;local subtitle_url=$(yt-dlp -q --skip-download --convert-subs srt --write-sub --sub-langs "en" --write-auto-sub --print "requested_subtitles.en.url" "$url")
local content=$(curl -s "$subtitle_url" | sed '/^$/d' | grep -v '^[0-9]*$' | grep -v '\--&amp;gt;' | sed 's/&amp;lt;[^&amp;gt;]*&amp;gt;//g' | tr '\n' ' ')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That first line retrieves a URL to the subtitles in WEBVTT format - I &lt;a href="https://gist.github.com/simonw/7f07837cf8adcee23fd5cd5394170f27"&gt;saved a copy of that here&lt;/a&gt;. The second line then uses &lt;code&gt;curl&lt;/code&gt; to fetch them, then &lt;code&gt;sed&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt; to remove the timestamp information, producing &lt;a href="https://gist.github.com/simonw/7f07837cf8adcee23fd5cd5394170f27?permalink_comment_id=5350044#gistcomment-5350044"&gt;this&lt;/a&gt;.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://davidgasquez.com/useful-llm-tools-2024/"&gt;Useful LLM tools (2024 Edition)&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/youtube"&gt;youtube&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm"&gt;llm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/zsh"&gt;zsh&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/jina"&gt;jina&lt;/a&gt;&lt;/p&gt;



</summary><category term="youtube"/><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="llm"/><category term="zsh"/><category term="jina"/></entry><entry><title>Shell History Is Your Best Productivity Tool</title><link href="https://simonwillison.net/2024/Apr/10/shell-history-is-your-best-productivity-tool/#atom-tag" rel="alternate"/><published>2024-04-10T23:17:59+00:00</published><updated>2024-04-10T23:17:59+00:00</updated><id>https://simonwillison.net/2024/Apr/10/shell-history-is-your-best-productivity-tool/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://martinheinz.dev/blog/110"&gt;Shell History Is Your Best Productivity Tool&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Martin Heinz drops a wealth of knowledge about ways to configure zsh (the default shell on macOS these days) to get better utility from your shell history.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://lobste.rs/s/zfcis3/shell_history_is_your_best_productivity"&gt;lobste.rs&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/productivity"&gt;productivity&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/shell"&gt;shell&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/zsh"&gt;zsh&lt;/a&gt;&lt;/p&gt;



</summary><category term="productivity"/><category term="shell"/><category term="zsh"/></entry><entry><title>llmc.sh</title><link href="https://simonwillison.net/2024/Feb/16/llmcsh/#atom-tag" rel="alternate"/><published>2024-02-16T18:19:41+00:00</published><updated>2024-02-16T18:19:41+00:00</updated><id>https://simonwillison.net/2024/Feb/16/llmcsh/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://gist.github.com/montasaurus/5ccbe453ef863f702291e763b1b63daf"&gt;llmc.sh&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Adam Montgomery wrote this a neat wrapper around my LLM CLI utility: it adds a “llmc” zsh function which you can ask for shell commands (llmc ’use ripgrep to find files matching otter’) which outputs the command, an explanation of the command and then copies the command to your clipboard for you to paste and execute if it looks like the right thing.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/montasaurus_rex/status/1758506549478097383"&gt;@montasaurus_rex&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/cli"&gt;cli&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llm"&gt;llm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/zsh"&gt;zsh&lt;/a&gt;&lt;/p&gt;



</summary><category term="cli"/><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="llm"/><category term="zsh"/></entry><entry><title>direnv</title><link href="https://simonwillison.net/2017/Nov/5/direnvdirenv-unclutter-your-profile/#atom-tag" rel="alternate"/><published>2017-11-05T19:59:35+00:00</published><updated>2017-11-05T19:59:35+00:00</updated><id>https://simonwillison.net/2017/Nov/5/direnvdirenv-unclutter-your-profile/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/direnv/direnv"&gt;direnv&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
A shell extension (for bash, zsh and others) which can automatically set and unset environment variables when you cd into specific directories. Useful for managing things like a project’s GOPATH or automatically activating Python virtual environments.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://speakerdeck.com/farslan/go-at-digitalocean?slide=32"&gt;Go at DigitalOcean&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/bash"&gt;bash&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/shell"&gt;shell&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/zsh"&gt;zsh&lt;/a&gt;&lt;/p&gt;



</summary><category term="bash"/><category term="shell"/><category term="zsh"/></entry></feed>