Skip to content

Instantly share code, notes, and snippets.

@rainbow23
Last active September 5, 2025 06:48
Show Gist options
  • Save rainbow23/134d629adb64a9ef304e52a7644e5ef4 to your computer and use it in GitHub Desktop.
Save rainbow23/134d629adb64a9ef304e52a7644e5ef4 to your computer and use it in GitHub Desktop.
bashrc 入力中の文字列をvimに表示する方法
# 現在の行を Vim で編集し、結果をプロンプトに戻す(自動実行しない)
__edit_line_in_vim() {
local tmp
tmp=$(mktemp /tmp/cmd.XXXXXX)
printf '%s\n' "$READLINE_LINE" > "$tmp"
"${VISUAL:-${EDITOR:-vi}}" "$tmp" < /dev/tty > /dev/tty 2>&1
READLINE_LINE="$(cat "$tmp")"
READLINE_POINT=${#READLINE_LINE}
rm -f "$tmp"
}
bind -x '"\C-e": __edit_line_in_vim'
@rainbow23
Copy link
Author

ああ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment