gedit command not found in Terminal

Joined
May 27, 2011
Messages
4
Reaction score
0
Points
1
Hi,
I'm not sure if this is in the right place, so mods feel free to move it to the relevant subforum.

I am trying to set up gedit on my Mac, but the gedit command in the Terminal is not recognised.
I have downloaded gedit (and gfortran) so what should I do next?

Any advice appreciated.
I should also say that I'm relatively new to using Terminal, so feel free to break down any instructions! :D
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Moved to a more appropriate forum.

No need to download the source and compile the code (I can imagine that getting all the dependencies working together would be a pain unless you used a package manager) - you can get gedit here as a precompiled binary (see link on the right hand side).
 
OP
C
Joined
May 27, 2011
Messages
4
Reaction score
0
Points
1
Yes, that's where I downloaded it from.
But when I run the 'gedit' command in Terminal, it is not recognised.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
No need to run it from the command line - it's a regular application bundle. Just double click it, after you've dragged it out the dmg, and it should run.
 
OP
C
Joined
May 27, 2011
Messages
4
Reaction score
0
Points
1
I can open it from its icon no problem, but if I'm working on compiling programmes in the Terminal, it would be handy to be able to use it to open files using gedit.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Try specifying it's path. If that works, add it to your $PATH. That should work, else then you could use open. Personally, I just use vi because I'm lazy.. and it's on every system out there.


Actually, since it's a gui application use this.


open <filename>

That will open to the registered application. Or you could do..

open -a /path/to/gedit <filename>
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
One thing to note about the open command: if you use the -a switch, open assumes you're referring to an application in the /Applications folder (it may check user application folders too but I'm not sure) so you won't have to provide the full path if that's where it is. If it's not in the /Applications folder, you'll need to provide the full path as noted by Dysfunction.
 
OP
C
Joined
May 27, 2011
Messages
4
Reaction score
0
Points
1
Okay thanks - the open command works fine - that should do.
And the other editors as well - I'm not particularly fussy about which one I use because I don't understand the differences between them yet, being a relative beginner, but gedit is the only one I have used before.

One final thing - what's the best/most efficient way to compile programmes? Is there a compiler built in to my Mac?
I have downloaded gfortran and I have found the g++ commands in a folder in the / directory, but I don't know how to make that command be recognised in my home directory where I'll be working. Any advice on that?

Thank you.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
While the gcc compiler isn't built into the OS out of the box, it is included in Xcode (which is a full IDE as well). This should be on one of the two disks that were supplied with the machine, or you can download it from Apple (there's a 3.x version that is free and a 4.x version which is $5). The former is available from their developers site (you need to register, it's free) and the latter is available on the app store.

Now, to be able to run a command in Unix in general it either needs to be in your path or you'd need to run the full path.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
If you're not picky about editors, you might be better served by a native Mac editor. gedit inherits some of the idiosyncrasies of GTK that appear when using it in OS X. There are lots available so I'll let you decide which one you want to use but I would suggest that you look around.
 
Joined
Dec 21, 2011
Messages
2
Reaction score
0
Points
1
This is the top result for "gedit mac terminal".

The answer in this thread for what OP asked isn't very clear.

If you've already installed the Mac gedit Application from the dmg here is how you get it to work in terminal.

1. In terminal, sudo nano [or other text editor] /etc/paths.
2. Add /Applications/gedit.app/Contents/MacOS/ to the list. (This points to where the gedit binary is.)
3. Save paths file (in nano this is ctrl-o).
4. Reload terminal.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
The answer in this thread for what OP asked isn't very clear.
Try specifying it's path. If that works, add it to your $PATH. [...] open <filename>

That will open to the registered application. Or you could do..

open -a /path/to/gedit <filename>

Okay thanks - the open command works fine - that should do.
Evidently it does. ;)

Your solution would work if you wanted to add the gedit command permanently to the PATH but it's not required.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
For the record it's not a good idea to edit anything in /etc. The best way to do this is copy the bashrc file in /etc to your home dir and edit it.
Then rename it to .bashrc (notice the dot in front).

Editing directly in /etc makes changes for ALL users which may not be a good thing. (not to mention that you don't own the files, system does)
 
Joined
Dec 21, 2011
Messages
2
Reaction score
0
Points
1
Evidently it does. ;)

Your solution would work if you wanted to add the gedit command permanently to the PATH but it's not required.

That's not what I or anyone else finding this page wants.

I want to simply enter "gedit" and get gedit like you would in Linux. open doesn't do that.

Sure you can set up an alias, edit the .bashrc, etc., but no one actually explained step-by-step how to do that and I wanted to put an easy solution on this page for anyone who stumbles upon this in the future.

- Helpful Googler
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top