LoginSignup
1
2

More than 5 years have passed since last update.

iTerm2 with PPTP

Last updated at Posted at 2018-02-11

やったこと

aスクリーンショット 2018-02-07 12.53.51.png (126.1 kB)

なぜやろうと思ったか

コマンドミスったりした時に

bash
-bash: テキトーなコマンド: command not found

これでは寂しいと思った。
こういうのは多少過激な方が面白いもんです。

必須環境

  • mac
  • iTerm2
  • imgcat
  • bash 4.x系

下準備

  • command_not_found_handleを使います。

  • bashのバージョンを確認しましょう

bash
$ bash --version

 おそらくmacの標準で入っているbashだと3.x.x系だと思います。
 3系だとcommand_not_found_handleはサポートされてないので使えません。
- bashのバージョンを4系にしましょう

bash
$ brew install
bash
$ which bash

とやると
/usr/local/bin/bashにインストールされていると思います。
このままでは変更されないので、ログインシェルの変更をします。

bash
$ sudo vi /etc/shells

/usr/local/bin/bashを追加してあげます。
追加したら

bash
$ chsh -s /usr/local/bin/bash

ターミナルを再起動....

bash
$ bash --version
GNU bash, バージョン 4.4.12(1)-release (x86_64-apple-darwin17.0.0)

こんな感じになっていればOK
- imgcatの導入
https://github.com/eddieantonio/imgcat

brew tap eddieantonio/eddieantonio
brew install imgcat
この二つを実行してやればOK

bash
$ imgcat -v
imgcat 2.1.0

これで下準備は終わりです

実装

  • .bashrcに関数を書く
bash
$ vi .bashrc
.bashrc
function command_not_found_handle(){
  if [ -e お好きな画像のパス ];then
     imgcat お好きな画像のパス
  fi
}
  • bash_profileにフックする
$ vi .bash_profile
.bash_profile
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

こんな感じで追加してやりましょう。

  • 編集した内容を実行させるためのやつ
bash
$ source ~/.bash_profile

を実行しましょう。

これで終わりです!これでコマンドミスも楽しくなるのです!

まとめ

思いつきでやったけども意外と時間かかった。
特にbash_profileのところ。。。

エイリアスとか色つけたりって便利なカスタマイズはあるけどこういう無駄なカスタマイズの方が僕は好きです!

1
2
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
1
2