4

do remote ssh connection in my tmux terminal (zsh) and remote shell is also zSH.

[devops@postgres-prod]~% vi /var/lib/pgsql/9.6/etc/postgresql.conf^A0A^A^A^E^A

So it doesn't react on Ctrl+A, Ctrl+E

slava
  • 161
  • 2
  • 11
DmitrySemenov
  • 835
  • 2
  • 15
  • 27

2 Answers2

2

Okay found what was the problem.

I had 'vim' mode zsh enabled by default for some reason.

I had to put the following into ~/.zshrc

# Emacs mode
bindkey -e

https://dougblack.io/words/zsh-vi-mode.html

Now everything works as expected.

DmitrySemenov
  • 835
  • 2
  • 15
  • 27
  • The reason was probably that the `EDITOR` or `VISUAL` environment variable was set to something conaining the substring "vi". In that case `zsh` starts with vi-mode. – Adaephon Apr 21 '17 at 07:58
1

You can keep using vim mode in zsh. I used these bindkey in .zshrc to fix the issue:

bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line

You may find other settings also helpful:

# use vim input mode
set -o vi
bindkey -v

# enable ctrl R to search history
bindkey '^R' history-incremental-search-backward

# enable navigation using Home and End key
#bindkey "${terminfo[khome]}" beginning-of-line
#bindkey "${terminfo[kend]}" end-of-line
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line

# enable Del key to delete char
bindkey "^[[3~" delete-char
# enable Alt + Bs key to delete word (forward)
bindkey "^[^?" backward-delete-word
# enable Alt + Del key to delete word (backword)
bindkey "^[^[[3~" delete-word
Beeno Tung
  • 113
  • 4