문제

프로그래밍 관점에서 Bash Shell을 VI 또는 EMAC를 통해 사용하도록 설정할 때

set -o vi

또는

set -o emacs

실제로 여기서 무슨 일이 일어나고 있습니까? Bash Shell 이이 편집자 중 하나를 쉘 자체에 입력하기 위해이 편집자 중 하나를 사용한다고 주장하는 책을 읽었지만 Readline을 사용했을 수도 있다고 생각했습니다.

도움이 되었습니까?

해결책

Bash는 여전히 Readline을 사용하고 있습니다. Readline은 EMAC 또는 VI 모드를 사용하고 다양한 편집기 모드간에 모드 스위치를 설정합니다. 기본 소스 코드에서 LIB/Readline 폴더를 확인하여 다양한 주요 바인딩을 확인할 수 있습니다.

다른 팁

Man Page에 따르면 bash_builtins (1) (Fedora 8) :

   set [--abefhkmnptuvxBCHP] [-o option] [arg ...]

... (모든 단일 문자 옵션 건너 뛰기)

         -o option-name
            The option-name can be one of the following:

...

            emacs   Use  an  emacs-style  command  line  editing interface.  This is
                    enabled by default when the shell  is  interactive,  unless  the
                    shell is started with the --noediting option.
...
            vi      Use a vi-style command line editing interface.
나는 Bash가 라인 편집의 명령을 직접 해석한다는 것을 의미한다고 해석합니다. 이 옵션은 단순히 사용하도록 설정 한 명령을 설정합니다. Readline (3)의 Man Page를 참조하십시오.

해당 편집자 사용자에게 익숙한 키 스트로크를 사용하여 명령 줄을 편집합니다.

Readline은 배쉬 및 기타 프로그램에 해당 기능을 제공하는 시설입니다.

에서 man bash:

READLINE
       This is the library that handles reading input when using  an  interac‐
       tive shell, unless the --noediting option is given at shell invocation.
       Line editing is also used when using the -e option to the read builtin.
       By default, the line editing commands are similar to those of emacs.  A
       vi-style line editing interface is also available.  Line editing can be
       enabled  at  any  time  using  the -o emacs or -o vi options to the set
       builtin (see SHELL BUILTIN COMMANDS below).  To turn off  line  editing
       after  the  shell  is running, use the +o emacs or +o vi options to the
       set builtin.

내가 아는 바에서 readline Bash의 라인 편집 기능을 제공하는 것입니다.

하나의 조항 : 누를 때 v VI 명령 모드에서는 완전히 날려 버립니다. vi 명령 줄을 편집 할 편집기.

에서 man bash:

읽기
이것은 대화 형 쉘을 사용할 때 읽기 입력을 처리하는 라이브러리입니다. --noediting 쉘 호출시 옵션이 제공됩니다. 기본적으로 라인 편집 명령은 EMACS와 유사합니다. VI 스타일 라인 편집 인터페이스도 제공됩니다. 쉘이 실행 된 후 라인 편집을 끄려면 +o emacs 또는 +o vi 옵션 set 내장.

쉘이 프롬프트를 제공 할 때 (비 편집 모드에 있지 않는 한) 이미 사용 readline. EMACS 모드 또는 VI 삽입 모드에있을 것입니다 (이는 만 사용할 수있는 이유입니다. ESC VI 명령 모드로 돌아갑니다).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top