22
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

超便利!Zshで、実行しようとしているコマンドをエディタで編集する

Last updated at Posted at 2016-09-29

Zsh使いには当然かもしれませんが・・・

動機

シェルでコマンドを入力している時に、複数行になったり、長くなったりすると編集するのが辛い。

特にワンライナーが長すぎて、何回もパイプが使われていると、非常に見づらい。

C-x C-eを押してみよう

そんな時に、C-x C-e を押すと、エディタが立ち上がり、現在入力されているコマンドを編集できる。

エディタを抜けると、コマンドが編集されているので、あとはそれを実行すれば良い。

別ファイルに保存しておくこともできるので、「現在打っているコマンドを保存したい」みたいな用途でも使えるかもしれない。

自分は今までこれの実現のために、わざわざecho [command] > /tmp/aみたいなことをしていた・・・

補足

ここで立ち上がるエディタは、環境変数$VISUALで決まる。
なのでexport VISUAL=emacsなどとすると変更できる。

22
25
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?