Skip to content

About ZSH suffix aliases

A recent post by Thorsten Hans describing the multiple ways to create ZSH aliases contains a section on suffix aliases, which I hadn’t known about.

Using the -s flag, you can instruct ZSH to open files ending in a specific suffix or with a specific file extension using an application of your choice.

For example, the following suffix alias will translate a call to example.json into code example.json, and open the file in Visual Studio Code:

alias -s json=code

You can assign multiple suffixes as well:

alias -s {js,ts}=code