Node.js devs, so picture this: you run `npm install` and you get a bunch of packages with audit errors.

The only thing I want to know at that point is what’s the root package that these dependencies belong to? (Running npm audit fix is a last resort as I don’t like it fiddling around with the dependencies of nested packages.)

It’s also not a straightforward thing to do, but it’s nothing jq and a bit of piping can’t fix:

```bash
npm audit --json | jq -r '.vulnerabilities[].name' | xargs -n1 npm ls
```

If you’re using fish shell, add an abbr(aviation) or an alias to that with a name like npm-audit-tree and you’re golden ;)

```bash
abbr --add --global npm-audit-tree 'npm audit --json | jq -r '.vulnerabilities[].name' | xargs -n1 npm ls'
```

(I usually prefer abbreviations to aliases as I like to remember/see the actual command being executed.)

Enjoy 💕

#NodeJS #npm #audit #security #JavaScript #JSON #jq #xargs #dev #tip

@aral I started using fish two months ago after using zsh for years. Abbreviations were such a cool new concept to see.

> I usually prefer abbreviations to aliases as I like to remember/see the actual command being executed.

I prefer abbrevations over aliases in fish for the same reason. 🙂

In zsh, you can recreate this behavior by adding this code into your .zshrc file:

```
expand-alias() {
zle _expand_alias
zle self-insert
}
zle -N expand-alias
bindkey -M main ' ' expand-alias
```

In zsh, every time you now type a space, zsh will automatically "expand" the word you just typed if it's an alias.

In bash you can simultaneously press Control Alt and e to manually "expand" the alias.

For macOS users, that last key combination won't work out of the box because macOS doesn't know the Alt key. The Option key of macOS is different from the Alt key. On macOS, you have to find the setting in your terminal emulator to "Treat Option as Alt". But then you won't be able to type ~ or @ into your terminal anymore. Ghostty, for example, allows to set only one of the two Option keys as the Alt key and leave the other Option key for symbols like ~ or @.

#shell #fish #zsh #bash #til

@aral Fun fact about zsh: The creator of zsh had a Chinese colleague, named Zheng Shu or something like that. (Sorry to all Chinese people for my ignorance.)

Their workplace created the usernames for the shared computer by using the first letter of the first name and the first two letters of the last name. My username would have been dcu.

Knowing the Bourne Again Shell (bash) and C Shell (csh), the creator of this new shell saw the username zsh of his Chinese colleague and thought this would make for a cool name for a shell. That's how the Z Shell was named.

#zsh #til

@davidculley @aral picked it up before 2.0, rolled it out to all my users (except those married to csh) under the banner “the shell to end all shells”. Good times. Solaris 4.1, Ultrix 4.2 probably.
@js I think I wasn't born yet at that time. 😅 Although I don't know the year that was.
@davidculley In my recollection, probably end ‘80s.