0% found this document useful (0 votes)
4 views1 page

Opening Files in External Programs

The document discusses how to open files in external programs using Bash and Z Shell commands, specifically highlighting the use of 'open' in macOS and 'xdg-open' in Linux. It explains how to open files in specific programs and manage processes in the terminal, including running commands in the background. Additionally, it introduces suffix aliases in Z Shell for setting default programs for specific file extensions.

Uploaded by

akym
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Opening Files in External Programs

The document discusses how to open files in external programs using Bash and Z Shell commands, specifically highlighting the use of 'open' in macOS and 'xdg-open' in Linux. It explains how to open files in specific programs and manage processes in the terminal, including running commands in the background. Additionally, it introduces suffix aliases in Z Shell for setting default programs for specific file extensions.

Uploaded by

akym
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

"Managing Files Using Bash and Z Shell" course by Mateo Prigl at Pluralsight

Opening Files in External Programs


Some files like images, doesn't make much sense if you cannot sense unless
you can see them (or listen to them!). For this we will need some additional
external software. You can use the open command in macOS to open a file in a
default external program. If you are trying to open an image, the image will be
opened inside of the Preview app. At least in the Catalina version.
In Linux you can do the same thing with the xdg-open command which is a
wrapper command for all kinds of custom commands that exist for each
desktop environment.
These command will open files in the default programs, but what if you want to
open files in some programs explicitly? You can do that by invoking the specific
command which refers to that program. For example, eog command starts the
eye of gnome which is an image viewing program in Gnome desktop
environment. However when you open an image with this command, the image
will be opened as a foreground process. This means that the terminal will be
blocked until you close the image.
You can get around this by putting the & character after the command. This
will put the process in the background. You can see all of the running processes
with the ps command.
In Z shell, there are suffix aliases. You can use this special kind of aliases to set
default programs which will run specific file extensions.
$ alias -s jpg=eog

This is how the suffix alias is set. If I now just type in the name of any jpg file,
without commands, the image will be opened inside of the eog.

1/1 © Copyright 2020 by Pluralsight

You might also like