M-x term
2011 년에 문제가 발생했을 때했던 것처럼 다른 모드를 고려해보십시오 .이 질문을 포함하여 Bash 완성으로 쉘 작업을 수행하기 위해 당시 Inet에 대한 모든 노력을 모 으려고 노력했습니다. 그러나 term-mode
나는 대안을 발견하기 때문에 시도조차하고 싶지 않습니다 eshell
.
완전한 터미널 에뮬레이터이므로 Midnight Commander와 같은 대화 형 프로그램을 내부에서 실행할 수 있습니다. 또는 zsh
완료로 전환하여 Emacs 구성에 시간을 낭비하지 않도록하십시오.
무료로 bash에서 TAB 완성을 얻습니다. 그러나 더 중요한 것은 증분 또는 접두사 명령 검색 과 같은 완전한 Readline 기능을 얻는 것 입니다. 이 설정을보다 편리하게하려면 .inputrc , .bashrc , .emacs를 확인하십시오 .
필수 부분 .inputrc
:
# I like this!
set editing-mode emacs
# Don't strip characters to 7 bits when reading.
set input-meta on
# Allow iso-latin1 characters to be inserted rather than converted to
# prefix-meta sequences.
set convert-meta off
# Display characters with the eighth bit set directly rather than as
# meta-prefixed characters.
set output-meta on
# Ignore hidden files.
set match-hidden-files off
# Ignore case (on/off).
set completion-ignore-case on
set completion-query-items 100
# First tab suggests ambiguous variants.
set show-all-if-ambiguous on
# Replace common prefix with ...
set completion-prefix-display-length 1
set skip-completed-text off
# If set to 'on', completed directory names have a slash appended. The default is 'on'.
set mark-directories on
set mark-symlinked-directories on
# If set to 'on', a character denoting a file's type is appended to the
# filename when listing possible completions. The default is 'off'.
set visible-stats on
set horizontal-scroll-mode off
$if Bash
"\C-x\C-e": edit-and-execute-command
$endif
# Define my favorite Emacs key bindings.
"\C-@": set-mark
"\C-w": kill-region
"\M-w": copy-region-as-kill
# Ctrl+Left/Right to move by whole words.
"\e[1;5C": forward-word
"\e[1;5D": backward-word
# Same with Shift pressed.
"\e[1;6C": forward-word
"\e[1;6D": backward-word
# Ctrl+Backspace/Delete to delete whole words.
"\e[3;5~": kill-word
"\C-_": backward-kill-word
# UP/DOWN filter history by typed string as prefix.
"\e[A": history-search-backward
"\C-p": history-search-backward
"\eOA": history-search-backward
"\e[B": history-search-forward
"\C-n": history-search-forward
"\eOB": history-search-forward
# Bind 'Shift+TAB' to complete as in Python TAB was need for another purpose.
"\e[Z": complete
# Cycling possible completion forward and backward in place.
"\e[1;3C": menu-complete # M-Right
"\e[1;3D": menu-complete-backward # M-Left
"\e[1;5I": menu-complete # C-TAB
.bashrc
(YEA! Bash에는의 모든 단어에서 dabbrev가 있습니다 ~/.bash_history
) :
set -o emacs
if [[ $- == *i* ]]; then
bind '"\e/": dabbrev-expand'
bind '"\ee": edit-and-execute-command'
fi
.emacs
용어 버퍼에서 탐색을 편안하게하려면 :
(setq term-buffer-maximum-size (lsh 1 14))
(eval-after-load 'term
'(progn
(defun my-term-send-delete-word-forward () (interactive) (term-send-raw-string "\ed"))
(defun my-term-send-delete-word-backward () (interactive) (term-send-raw-string "\e\C-h"))
(define-key term-raw-map [C-delete] 'my-term-send-delete-word-forward)
(define-key term-raw-map [C-backspace] 'my-term-send-delete-word-backward)
(defun my-term-send-forward-word () (interactive) (term-send-raw-string "\ef"))
(defun my-term-send-backward-word () (interactive) (term-send-raw-string "\eb"))
(define-key term-raw-map [C-left] 'my-term-send-backward-word)
(define-key term-raw-map [C-right] 'my-term-send-forward-word)
(defun my-term-send-m-right () (interactive) (term-send-raw-string "\e[1;3C"))
(defun my-term-send-m-left () (interactive) (term-send-raw-string "\e[1;3D"))
(define-key term-raw-map [M-right] 'my-term-send-m-right)
(define-key term-raw-map [M-left] 'my-term-send-m-left)
))
(defun my-term-mode-hook ()
(goto-address-mode 1))
(add-hook 'term-mode-hook #'my-term-mode-hook)
C-x o
터미널 에뮬레이션 모드에서 작동하지 않는 일반적인 명령으로 키맵을 다음과 같이 확장했습니다.
(unless
(ignore-errors
(require 'ido)
(ido-mode 1)
(global-set-key [?\s-d] #'ido-dired)
(global-set-key [?\s-f] #'ido-find-file)
t)
(global-set-key [?\s-d] #'dired)
(global-set-key [?\s-f] #'find-file))
(defun my--kill-this-buffer-maybe-switch-to-next ()
"Kill current buffer. Switch to next buffer if previous command
was switching to next buffer or this command itself allowing
sequential closing of uninteresting buffers."
(interactive)
(let ( (cmd last-command) )
(kill-buffer (current-buffer))
(when (memq cmd (list 'next-buffer this-command))
(next-buffer))))
(global-set-key [s-delete] 'my--kill-this-buffer-maybe-switch-to-next)
(defun my--backward-other-window ()
(interactive)
(other-window -1))
(global-set-key [s-up] #'my--backward-other-window)
(global-set-key [s-down] #'other-window)
(global-set-key [s-tab] 'other-window)
super
키를 사용 하므로 term-raw-map
다른 키맵이 키 바인딩과 충돌하지 않습니다. super
왼쪽 키에서 키 를 만들려면 다음을 Win
사용합니다 .xmodmaprc
.
! To load this config run:
! $ xmodmap .xmodmaprc
! Win key.
clear mod3
clear mod4
keycode 133 = Super_L
keycode 134 = Hyper_R
add mod3 = Super_L
add mod4 = Hyper_R
두 가지 명령을 기억해야합니다 C-c C-j
.-일반 Emacs 편집 모드로 들어가기 (버퍼 텍스트에서 복사 또는 grepping), C-c C-k
-터미널 에뮬레이션 모드로 돌아 가기.
마우스 선택과 Shift-Insert
같이 작업 xterm
.
eshell-mode
어떤 탭 완성을 가지고있다. 여기에 더 많은 정보 : masteringemacs.org/articles/2010/11/01/…