Emacs uses Multi-term
The multi-term in Emacs is equivalent to the iterm under the Mac and is a very useful terminal under Emacs.
Load Multi-term.el File
Emacs uses Multi-term as terminal, the first place to put Multi-term.el files in your Emacs Load-path.
Configuration
;;-------------------------------- ---------------------------- ; set Multi-term ;;------------------------------------------------------------ (require ' Multi-term) (setq multi-term-program "/bin /zsh ") ; Use of Emacs terminfo, not system terminfo, Mac system appears 4m setq system-uses-terminfo nil )
Here are a few points to note:
1. I use ZSH, if you are using bash, replace "/bin/zsh" with your "/bin/bash"
2. If you are using a Mac system, find that multi-term each line out of 4m, running in the shell: Tic-o ~/.terminfo/applications/emacs.app/contents/resources/etc/e /eterm-color.ti
3. Zsh may appear in Chinese as???? under Mac Case, this time create a file: ~/.zshenv, whose contents are as follows:
export LANG=‘en_US.UTF-8‘export LC_ALL="en_US.UTF-8"
Shortcut keys
The command to open Multi-term is multi-term, and you may find that there is a conflict with your shortcut keys in multi-term mode. If you want to keep your shortcuts in other mode, add shortcut keys to the term-bind-key-alist list, for example, I want to keep "c-j" like my other mode, as follows:
(add-to-list ‘term-bind-key-alist ‘("C-j"))
Solve a few annoying problems
1.I began to set the zsh, which I found, when I used d When the command changes the working directory, the default-directory variable in emacs does not change, making c-x c-f call Open file when the directory is not the current working directory?
Workaround put the following code into the zsh configuration file < Span class= "Mrow" id= "mathjax-span-6" > &NBSP; . z Span class= "Mi" id= "mathjax-span-10" style= "font-family:stixgeneral-italic;" >s h r c Allows Emacs to track changes in the path, reference 1, reference 2.
if"$INSIDE_EMACS" ]; then print"\033AnSiTc %d" } print"\033AnSiTu %n" print"\033AnSiTc %d"fi
2. I hope that when the cursor is not on the last line, the "c-a" function is to move the cursor to the beginning of the row, and when the cursor is in the last row, I want the "c-a" to move the cursor to the beginning of the command.
Workaround: Bind the following ab/move-beginning-of-line to the shortcut key "C-a".
; When you are on the last line, "C-a" moves the cursor to the beginning of terminal instead of the header of the row(defun ab/is-at-end-line ()"Determines if the last line"(equal ( Line-number-at-pos) (count-lines (point-min) ( Point-max )))) (defun ab/is-term-mode ()"Determines whether it is a term mode"(string= Major-mode "Term-mode")) (DefunAb/move-beginning-of-line() "Move Begin" (interactive) (if ( not (ab/is-term-mode))(beginning-of-line) (if ( not (ab/is-at-end-line))( Beginning-of-line)(term-send-raw ))))
3. There is an annoying problem, you find that using the "c-b" (Backword-char function), you want to insert a new character in the middle of the command, each time it is inserted into the end of this line.
Workaround: Bind the following Ab/backword-char function to "C-b"
;; only later when it is Term-mode and is the last line (Term-send-left)(DefunAb/backword-char() "Custom" (interactive) (if ( not (ab/is-term-mode)) (Backward-char) (progn (if ( not (ab/is-at-end-line))( Backward-char)(progn (term-send-left) (message "Term-send-left" ))))))
See my multi-term configuration for more
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Emacs uses Multi-term as terminal