14

When I was using a Linux laptop as my dev machine, I used to do "gedit xxxx" in a Terminal. Now I just switched to MacBook, I d like to do the same thing.

I know that I can open gedit in a command line like "open gedit", but can I add the file name? Otherwise I have to use vim. I am not a fan of vim.

Xi 张熹
  • 10,492
  • 18
  • 58
  • 86

4 Answers4

11

Add

alias gedit="open -a gedit"

to ~/.bash_profile :

Now you'll be able to gedit directly from the command line.

Rohit Vipin Mathews
  • 11,629
  • 15
  • 57
  • 112
jwalk
  • 126
  • 1
  • 2
  • 1
    Not exactly the same, because in Linux you can do `gedit nonexisting_file`, whereas Mac's `open` will say file does not exist. – ChronoTrigger Mar 06 '14 at 16:34
5

try:

open -a /path/to/gedit /path/to/file.txt
prodigitalson
  • 60,050
  • 10
  • 100
  • 114
2

I added the following to my PATH:

:~/Applications/gedit.app/Contents/MacOS/

and afterwards I was able to access gedit from the command line. One caveat: if gedit is not already running on the system, then it throws an error if I launch it from the command line. Once gedit is already running though, this works to open files in gedit from the command line.

To edit the path, open ~/.profile in an editor

dandelion
  • 1,742
  • 1
  • 15
  • 18
0

I use textmate for dev, here is a tutorial how it is done for Textmate

http://manual.macromates.com/en/using_textmate_from_terminal.html

I believe the same would apply to gedit.

Hope it helps

Quasar
  • 137
  • 3