Terminal
I hope you all had a good weekend and Easter. Today’s post is going to be a small follow on to Saturday’s post on editing your Bash profile. One of the comments gave me an idea of allowing you to open the file in TextEdit and edit the file from there, rather than trying to use Terminals built in file editor. I am going to expand on this and show you how to open a file from Terminal so you can edit in a different app. This is useful since you don’t have to fight with Terminal’s text editors, especially if you have limited knowledge of the workings or don’t like to use them.
Opening files is very simple. Within Terminal the function to open a file is called
open . In guessing for why they picked that name. The Terminal program can be used in various different ways, for example the following:
open file.txt
With the built-in Terminal app on your Mac, you can run a number of commands to execute various actions on your machine. From taking screenshots of your screens to renaming a whole bunch of files at once, Terminal commands cover a lot of things that you usually do on your machines. Terminal 101: The Open Command. With the directory path and file that you wish to open. When you press enter, a Mac app will launch, opening the file you’ve specified. With the name of.
Will open the file in TextEdit. If you want to apply this to the file in the previous post you can write:
open .bash_profile Best mac os apps.
Here you can edit the file in TextEdit, which makes life a lot easier.
You can also use the open program on a whole load of other file types. The following will work perfectly well, the last one will open a Finder window to a location instead of a file in an app.
open http://www.mactricksandtips.com
open image.jpg
open /path/to/folder
Each one will open the file, and URL’s, in the default app as supplied by your operating system. If you want to change which app it opens with you can modify how the app works. This is done with the following command.
open -a '/Applications/TextMate.app' text.txt
The “-a” command says “use this program instead”. Make sure when you list the file path you give the .app file extension (which is always present, just hidden) otherwise you will get an error.
If you want to open the program in the background use the -g option as such:
open -g text.txt Finally, instead of opening the file you can show it in Finder. This only works if you can already see the file, if the file is hidden (i.e starts with a dot) you just get the Finder window. open -R /path/to/file/file.txt
Overall the program is very useful, and I will begin to use it to edit files. I haven’t tested this however I have a feeling if you add “sudo” to the front of the command you will be able to edit files that you would normally need a password for. Try it out and see what happens. If you want more information on this command simply type “man open” into Terminal, there is a couple of other bits of information, the important bits are listed here.
Open Terminal In Mac
If you have any questions or comments please leave them below.
If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.
Mac Terminal Open File In AppleRelated posts:Where To Next?Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |