How to launch gedit from terminal and detach it (just like "subl" command works)?

You could use this function:

gedit() { /usr/bin/gedit $@ & disown ;}

It:

  • Makes a function which can be called with gedit
  • Launches gedit (using the full path /usr/bin/gedit), passing all the arguments/files given to it using $@
  • & disown sends it to background and disown detaches it from the terminal/shell.

If you're on a recent GNOME 3 setup you could also use gapplication1:

gapplication launch org.gnome.gedit sample.py

to launch gedit just like you'd launch it from the dash (detached from terminal).
Sure, you can always define an alias:

alias ged='gapplication launch org.gnome.gedit'

or a function:

ged () { gapplication launch org.gnome.gedit "$@"; }

This only works for D-Bus activatable applications (run gapplication list-apps to get a list of apps).