will sudo work like gksudo on Ubuntu?
No, it won't. To open the folder you're currently in, all you really need to do is type open .
. If you want to open a file, the same applies.
If you however need root permissions for a file, then you need to tell open
which application exactly to run. Normally, you would do this with open -a NameOfApplication
, like open -a TextEdit
, but TextEdit will still be run without root privileges if you call sudo open -a TextEdit
. This is because the process of opening is deferred from open
to a service in OS X that won't run as root.
The trick is to run the actual executable of the application you want to open with sudo
. For example:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /path/to/file
If you're lazy and want to repeat doing that, you could create an alias in your shell.
is it possible to use Sublime like gedit from terminal?
Much easier:
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
That requires ~/bin/subl
to be in your PATH
. Otherwise:
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /bin/subl
Then just run subl /path/to/file
.