Combining the above answers by Dick Kenny and Alberto Zaccagni you get the following configuration which I use in .bashrc
:
alias emacs='emacsclient -nw -c -a ""'
This will try to connect to a runnning emacs daemon. If none is running, it will startup a new one, and then connect using the current terminal window.
From the docs:
-a EDITOR, --alternate-editor=EDITOR
Editor to fallback to if the server is not running
If EDITOR is the empty string, start Emacs in daemon
mode and try connecting again
-nw, -t, --tty Open a new Emacs frame on the current terminal
-c, --create-frame Create a new frame instead of trying to
use the current Emacs frame