Emacs as an advanced terminal multiplexer

I really enjoy using Tmux and I love zsh, but I am missing something like ace-jump-mode to quickly jump to a line in my terminal and I would like to have snippets for everyday tasks like a for loop so some day I thought why not try using zsh in Emacs? And voila here is the config that let you jump around in your terminal by pressing “jj” and a head character as well as write you Yasnippets.
To use it you have to install multi-term, ace-jump-mode, key-chord and yasnippet.


(require 'multi-term)
(require 'ace-jump-mode)
(require 'key-chord)
(require 'yasnippet)

(key-chord-mode 1)
(setq key-chord-one-key-delay 0.15)
(key-chord-define-global "jj" 'ace-jump-mode)

(add-hook 'term-mode-hook (lambda ()
(setq yas/dont-activate nil)
(yas/minor-mode-on)
(add-to-list 'term-bind-key-alist '("C-c C-n" . multi-term-next))
(add-to-list 'term-bind-key-alist '("C-c C-p" . multi-term-prev))
(add-to-list 'term-bind-key-alist '("C-c C-j" . term-line-mode))
(add-to-list 'term-bind-key-alist '("C-c C-k" . term-char-mode))
))

(global-set-key (kbd "C-c t") 'multi-term-next)
(global-set-key (kbd "C-c T") 'multi-term)

Now you can open a new terminal by pressing C-c T, switch between them with C-c C-n and C-c C-p and if you would like to copy some text in the middle of your screen first press C-c C-j to enable line-mode than jj to jump. The same applies for yasnippets first switch from char to line-mode (it makes your terminal a normal emacs buffer), type your keyword and expand it with tab. Here’s an example


# key: for
# --
for X in $1; do $0; done

Advertisements

One thought on “Emacs as an advanced terminal multiplexer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s