In macOS terminal, you can use the
open command with the
-e flag to open a file for editing with the macOS
open -e /path/to/file
Once you're done editing the file, you can save it and then safely close the
TextEdit application. To view the changes you made to the file in terminal, for example, you can use the "
cat /path/to/file" command.
Another way to open the file for editing in macOS
TextEdit is to explicitly specify it as the application you wish to open the file with, for example, like so:
open -a TextEdit /path/to/file
-a flag allows you to specify the application you wish to open the file with. You can specify any application name (which is determined via "LaunchServices").
It is also worth mentioning the
-e flag, which allows you to open the file with the default text editor, as determined via "LaunchServices" (which is normally the
TextEdit application as well):
open -t /path/to/file
There are a lot of other useful options you can use with the
open command. To learn more about these you can always try the "
man open" command in macOS terminal.
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.