コマンドライン(bashとzsh)から単語を後ろに削除するには?

コマンドライン(bashとzsh)から単語を後ろに削除するには?

コマンドラインから単語を逆に削除する方法は?私はCtrl+を使用して最後の「単語」を削除するいくつかの編集者に慣れており、Backspaceコマンドラインでもその機能を使用できることを願っています。

私は現在Bashを使用しており、単語を後ろにスキップして将来の単語を削除できますが、むしろこれをショートカットとして使用したり、+Ctrlでイベントを使用したいと思いますBackspace

これはどのように達成できますか?

ベストアンサー1

Ctrl+Wは標準の「kill word」(別名werase)です。 Ctrl+Uライン全体を終了します(kill)。

で変更できますstty

-bash-4.2$ stty -a
speed 38400 baud; 24 rows; 80 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
        -extproc -xcase
iflags: -istrip icrnl -inlcr -igncr -iuclc ixon -ixoff ixany imaxbel
        -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl -onocr -onlret -olcuc oxtabs -onoeot
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
        min = 1; quit = ^\; reprint = ^R; start = ^Q; status = <undef>;
        stop = ^S; susp = ^Z; time = 0; werase = ^W;
-bash-4.2$ stty werase ^p
-bash-4.2$ stty kill ^a
-bash-4.2$

実際の制御文字を行にする必要はありません。stty配置を理解してから、^制御で描く文字を理解してください。

Ctrl次に+を押すと、そのP行から単語が削除されます。Ctrl+ をクリックすると、行A全体が削除されます。

おすすめ記事