Skip to content

[FR] Add ability to use iTerm as the default application for opening a file type

I don't know if this is already possible or not, but I searched, and I didn't find anything. So here I am.

I want to set iTerm as the default application for opening a file type. E.g., I want to do: image

Currently, this causes iTerm to try to execute the file, which obviously won't work. However, iTerm can add an ability to open files with specific extensions using specific commands. In this example, we want to tell iTerm to open files ending with .wav with the program mpv. zsh has something in this spirit, called suffix aliases:

❯ alias -s # lists all suffix aliases
TXT='emacsclient -t'
ace='unace l'
ape=mpv
asc='emacsclient -t'
at=lynx
avi=mpv
c='emacsclient -t'
cc='emacsclient -t'
com=lynx
cpp='emacsclient -t'
cx=lynx
cxx='emacsclient -t'
de=lynx
dk=lynx
flac=hear
flv=mpv
h='emacsclient -t'
hh='emacsclient -t'
htm=lynx
html=lynx
inl='emacsclient -t'
m4a=hear
m4b=hear
mkv=mpv
mov=mpv
mp3=hear
mp4=mpv
mpeg=mpv
mpg=mpv
net=lynx
nl=lynx
ogg=hear
ogm=hear
opus=hear
org=lynx
rar='unrar l'
rm=mpv
se=lynx
tar='tar tf'
tar.gz='echo '
tex='emacsclient -t'
txt='emacsclient -t'
wav=hear
webm=mpv
zip='unzip -l'

❯ alias -s wav=mpv # define new suffix alias

This causes zsh to, e.g., convert hi.txt 1 2 3 to emacsclient -t hi.txt 1 2 3.

A functionality similar to this, but implemented in iTerm will allow us to integrate the CLI apps much better with the GUI macOS.