Amelio Vazquez-Reina
Amelio Vazquez-Reina

Reputation: 96274

Emacs: Keyboard shortcut to run ansi-term with a specific shell

I would like to associate a keyboard binding in Emacs (e.g. C-c a) that automatically starts an ansi-term window with a shell that I have pre-specified in my .emacs file (without prompting anything)

For reference, there are two threads in StackOverflow that address similar problems:

but it isn't obvious to me how to combine the ideas in those threads to get an answer to my question.

Upvotes: 3

Views: 904

Answers (2)

Daimrod
Daimrod

Reputation: 5020

I suggest you to use multi-term. As its name implies, it lets you deal with multiple term using ansi-term.

Here is a small configuration:

(require 'multi-term)
(eval-after-load "multi-term"
                 '(setq multi-term-program "/bin/bash"
                   term-unbind-key-list '("C-x"
                                          "C-h"
                                          "M-x"
                                          "C-z")
                   term-term-name "xterm-256color"))
(global-set-key (kbd "C-c a") 'multi-term-next)

My whole configuration for multi-term is here (compilation-shell-minor-mode is really nice).

Upvotes: 1

Nicolas Dudebout
Nicolas Dudebout

Reputation: 9262

(global-set-key (kbd "C-c a") '(lambda () (interactive) (ansi-term "/bin/zsh")))

Upvotes: 7

Related Questions