LoginSignup
22
16

More than 5 years have passed since last update.

Ctrl+wを押した時にスラッシュまでを削除するようにするbash設定

Last updated at Posted at 2015-01-28

前提

  • 自分のMacでの動作を確認
    • Mac OS X ver 10.9.5
  • windowsでの動作検証を行っていませんが、bash環境なら同じ適用ができるはず…

やりたいこと

/hoge/foo/bar
の末尾でCtrl+wを押した時、
デフォルトでは全て消えてしまうが
/hoge/foo/
のようにスラッシュまで(1つ上の階層まで)消したい場合の設定方法

やること

~/.bashrc(ない場合は作成して下さい)に以下を記述
stty werase undef
bind '"\C-w": unix-filename-rubout'

次にそのbashを適用
source ~/.bashrc

これでスラッシュまでの削除になります!

この手の記事はいくつかありますが(これとか:http://qiita.com/ironsand/items/98a48e7a13be3d034688
bashに書く時のシングルクォーテーションとダブルクォーテーションに注意です。

説明


ざっくり説明すると
stty werase undef
これで元々のCtrl+wのキーバインドを削除
bind '"\C-w": unix-filename-rubout'
これで新しくCtrl+wを設定
unix-filename-ruboutの箇所は他にも色々な設定がある
詳しくは以下URL
https://www.gnu.org/software/bash/manual/html_node/Commands-For-Killing.html
ハイフンやアンダースコア区切りもあるっぽい

22
16
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
16