Question or issue on macOS:
In the Windows command prompt, I can type notepad helloworld.cpp which will then create a .cpp file with the name helloworld and open up Notepad for me.
Is there a similar function for Mac Terminal, preferably with Textmate or Textedit?
I’m running Mac OS X Lion 10.7, with Xcode developers tool.
How to solve this problem?
Solution no. 1:
There are plenty of ways. Try:
- Use command-line text editors in Terminal on Mac. To edit a plain text file in Terminal, you can use a command-line text editor. For general-purpose work, it’s easiest to use one of the text editors included with macOS. If you want to use a graphical text editor, use TextEdit (in Launchpad).
- Open your terminal application - Applications - Utilities - Terminal.app Type the following or copy this into your terminal app and then press enter: chflags nohidden /Library/ Exit the terminal by typing in exit or just close it. After doing that, follow the path that I gave you above in my other reply.
- You can open up Terminal on your Mac (perhaps by opening Spotlight on your Mac with Command⌘-Space key combination and type “Terminal”. Traverse to a folder you want to work in (documents will do, but it might get a little bit messy!). You can move through the text editor using the cursor keys, or JKJL.
First, it is easier to use, and second, it does not require the Terminal remain open: open -a appname. In this command, replace “appname” with the name of your desired app, and it should launch. Note that by default this command will, similar to the OS X graphical environment, only open one instance of an app, so if the program is already. How to open the Terminal on a Mac. Open -a Text Edit FILE PATHWAY If you need to get to your Terminal's settings, hold down the command key while tapping the comma button. And, in case you.
vi <filename you want to save or open.cpp>
,pico
,Open /Applications/TextEdit.app <filename>
.
Solution no. 2:
The option -e
is used to open the file <filename>
with TextEdit.
Solution no. 3:
Simply use open <filename>
command as described in this article. It will open an app associated with the file type.
Use open -e
to open /Applications/TextEdit
Solution no. 4:
About some of the previous suggestions here – you can use open
command combined with a
flag to open a file with specific application:
open -a [appname] [filename]
but if [filename]
doesn’t exist it displays an error the file doesn't exists
or something like that, and doesn’t create the required file, as you have requested.
Write the following to your ~/.bashrc
file (if that file doesn’t exists, you can create it by writing touch ~/.bashrc
inside the terminal):
And use it like this:
open2 [appname] [filename]
Note that appname
is an application in your installed application folder (/Applications
).
The command touch
creates you the required file (don’t worry, if the file exists it won’t remove / reset the current file, only redefine the modification time to the current time).
Solution no. 5:
Open A File From Terminal
The problem with:
or
is that you have no control on the TextEdit.app modes: Plain Text or RichText.
Mac Os Open Textedit From Terminal
E.g. if you try to open an HTML file, TextEdit will open it in the Rich Text mode, not in the Plain Text mode, as expected. Then switching to the Plain Text mode will not show the HTML tags.
I could not find a Terminal command to activate the Open option:
or the Preference setting:
As far as I can see, even an osascript won’t solve the case.
This is unfortunate since TextEdit.app is the only text editor that is present for sure. Not all Mac users have installed BBedit, TextMate, or any other third party editor and even less users have defined a “default editor”.
Solution no. 6:
If your using text mate you can set it up to work with terminal
Taken from
Once you’ve got mate into your path you can type the following into the terminal
Mac Text Editor Terminal
if you want text mate to display all files in a folder as a project drawer
Solution no. 7:
Textedit For Mac
Go to Preferences (⌘+,) & install shell support.
Launch Textedit From Command Line Mac
Then you could open any files from terminal with:
or
Open Textedit From Terminal Mac Os
Solution no. 8:
The answer to the question, for me, was:
leafpad
Best Text Editor Linux
Hope this helps!
Fostering innovative and open methods and tools in the classroom and beyond.
Expanding the scope and impact of traditional and digital humanities for the contemporary world.
Thinking critically about the role and design of technology, data and the social sciences in our lives and learning.
Promoting openness, access, and diversity in technology, and education in service of an equitable society.
Promoting change in schools, museums, libraries, and other organizations.
Advocating for new forms of scholarly communications, including blogging, multimedia, open publishing, and academic journals and presses.