I want to open videos and pictures from my command line shell.
Is there a way terminal app can do this?
To open any file from the command line with the default application, just type open
followed by the filename/path.
Example:
open ~/Desktop/filename.mp4
Edit: as per Johnny Drama's comment below, if you want to be able to open files in a certain application, put -a
followed by the application's name in quotes between open
and the file.
Example:
open -a "QuickTime Player" ~/Desktop/filename.mp4
If you need further information about the open
command, type man open
.
open -a "Application" /Path/to/file
. Example: open -a "Adobe Photoshop CC 2014" ~/Desktop/test.psd
. See man open
for more information.
open -a /path/to/MyApp.app /path/to/file.txt
I wrote a guide on how to open a file in terminal which includes instructions for Windows and Linux as well, but to summarize for both the OP and others who find this page (to be complete, I showed how to do this in command prompt as well):
Navigate to the file's directory:
cd /path/to/directory
Open the file:
In macOS
open filename.txt
or use editors like vi, emacs, nano. Example:
vi filename.txt
Opening Other Files in Terminal:
macOS:
PDFs: open filename.pdf
Images: open filename.jpg
Webpages: open http://www.example.com
It can also be done by using xdg-open filename
.
Command will open the file with it's default application and it also used to open the urls .