You can set up emacs as an edit server so instead of starting a new instance of emacs,
it “listens” for external edit requests
so you can use emacsclient -t somefile.txt to open the file in the terminal
but thats too much too type so i created a simple function called e that accepts multiple files and opens them in emacsclient in the terminal
add the following code to your ~/.emacs config to start the emacs server when you open emacs
set emacs as your editor in your ~/.bashrc
add the function to your ~/.bashrc
source your ~/.bashrc to pick up the changes
now you can edit files with emacsclient by typing
you can also pass multiple files to the function which will open the files in different buffers in emacsclient
we use $@ in the function which accepts multiple files as arguments
instead of $1 which only accepts 1 file
its better to use a function instead of an aliases
as i have found that pressing tab to autocomplete the file name doesnt work with an alias
unless you expand the alias first and then press tab
it “listens” for external edit requests
so you can use emacsclient -t somefile.txt to open the file in the terminal
but thats too much too type so i created a simple function called e that accepts multiple files and opens them in emacsclient in the terminal
add the following code to your ~/.emacs config to start the emacs server when you open emacs
Bash:
; emacs server start for emacsclient
(server-start)
set emacs as your editor in your ~/.bashrc
Bash:
# set emacslient as editor
ALTERNATE_EDITOR=""; export ALTERNATE_EDITOR
EDITOR="/usr/local/bin/emacsclient -t"; export EDITOR
VISUAL="/usr/local/bin/emacsclient -c -a emacs"; export VISUAL
add the function to your ~/.bashrc
Bash:
# emacsclient function e
function e {
/usr/local/bin/emacsclient -t "$@"
}
source your ~/.bashrc to pick up the changes
Bash:
. ~/.bashrc
now you can edit files with emacsclient by typing
Bash:
e somefile.txt
you can also pass multiple files to the function which will open the files in different buffers in emacsclient
Bash:
e somefile.txt somefile2.txt somefile3.txt
we use $@ in the function which accepts multiple files as arguments
instead of $1 which only accepts 1 file
its better to use a function instead of an aliases
as i have found that pressing tab to autocomplete the file name doesnt work with an alias
unless you expand the alias first and then press tab