@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Bash 現在の編集モードを確認する

  1. set -o
  2. shopt -o
  3. bind -V | grep editing-mode

emacs - How to set and determine the command-line editing mode of Bash? - Unix & Linux Stack Exchange

set -o

bash-3.2$ set -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off

shopt -o

bash-3.2$ shopt -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off

bind -V

bash-3.2$ bind -V
bind-tty-special-chars is set to `on'
blink-matching-paren is set to `on'
byte-oriented is set to `off'
completion-ignore-case is set to `off'
convert-meta is set to `off'
disable-completion is set to `off'
enable-keypad is set to `off'
expand-tilde is set to `off'
history-preserve-point is set to `off'
horizontal-scroll-mode is set to `off'
input-meta is set to `on'
mark-directories is set to `on'
mark-modified-lines is set to `off'
mark-symlinked-directories is set to `off'
match-hidden-files is set to `on'
meta-flag is set to `on'
output-meta is set to `on'
page-completions is set to `on'
prefer-visible-bell is set to `on'
print-completions-horizontally is set to `off'
show-all-if-ambiguous is set to `off'
show-all-if-unmodified is set to `off'
visible-stats is set to `off'
bell-style is set to `audible'
comment-begin is set to `#'
completion-query-items is set to `100'
editing-mode is set to `emacs'
keymap is set to `emacs'
bash-3.2$ bind -V | grep -E 'editing-mode|keymap'
editing-mode is set to `emacs'
keymap is set to `emacs'
  • shopt -o は set -o と同じ?
  • bind -V で見えるのは readline の変数

Zsh の場合は ZLE (Zsh Line Editor) という機能?がコマンド行の編集に使われているので、上記の設定は無関係っぽい。

zsh: 18 Zsh Line Editor

マニュアル読んでも現在の設定内容の調べ方がわからなかった。変更方法は bindkey -e bindkey -v

http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Keymaps

In addition to these names, either ‘emacs’ or ‘viins’ is also linked to the name ‘main’. If one of the VISUAL or EDITOR environment variables contain the string ‘vi’ when the shell starts up then it will be ‘viins’, otherwise it will be ‘emacs’. bindkey’s -e and -v options provide a convenient way to override this default choice.

とあるので、「デフォルトは emacs キーバインド」ということで良いのだろう。