1) install the gedit app
(This can be found at their project page: http://projects.gnome.org/gedit/)
Caution: if you don't know what "sudo" is, how to write shell scripts, or what file permissions are, read up on it before doing the next few steps or you could potentially screw up your system.
2) create a shell script named 'gedit' in a folder defined in your PATH (in my case, I just put it in /usr/bin), and have it open a file using gedit
In the terminal, create a new shell script named 'gedit' using a text editor. In this example we use the 'nano' text editor.
sudo nano /usr/bin/gedit
Type in the following script:
#!/bin/bash
open -a /Applications/gedit.app/Contents/MacOS/gedit $1
Save.
This lets you do simple "gedit something.txt" or "gedit" commands from the terminal. You can change this script as you desire for more complicated behavior.
3) make the script executable
sudo chmod +x /usr/bin/gedit
To test if this worked out, open up a file using gedit in the terminal, e.g. "gedit myfavoritefile.txt"
4) how to undo this
To undo all of this, simply delete the /usr/bin/gedit script you created and uninstall gedit.
Hello,
ReplyDeleteThank you for your help. I am just wondering if it's also possible to edit this script so you can create a file with gedit as well.
For example, typing 'gedit newfile.c' gives the following error:
'The file /Users/me/newfile.c does not exist.'
Thank you!