3

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.

Community
  • 1
  • 1
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564

2 Answers2

7

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

Nicolas Dudebout
  • 9,172
  • 2
  • 34
  • 43
1

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).

Daimrod
  • 4,902
  • 23
  • 25