Last active
September 5, 2025 06:48
-
-
Save rainbow23/134d629adb64a9ef304e52a7644e5ef4 to your computer and use it in GitHub Desktop.
bashrc 入力中の文字列をvimに表示する方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 現在の行を 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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ああ