Tambourine作業メモ

主にスキル習得のためにやった作業のメモ。他人には基本的に無用のものです。

fish

Software Design 2016/06号の特集「bash 再入門」を読んで、fishが面白そうだと感じたため、bashを使うのをやめた。「bash 再入門」する日はくるだろうか(笑)

インストールは brew install fishでOK

.bash_rcに書くようなことを ~/.config/fish/config.fish に書けばいいらしい。ちょっと構文が違うので戸惑う。特にrbenvが要求する

eval $(rbenv init -)

をどうしたらいいのかわからない。というか、なんでevalしているのかわからない。

コマンドを実行してみる

~> rbenv init -
setenv PATH '/Users/tambara/.rbenv/shims' $PATH
setenv RBENV_SHELL fish
. '/usr/local/Cellar/rbenv/1.0.0/libexec/../completions/rbenv.fish'
command rbenv rehash 2>/dev/null
function rbenv
  set command $argv[1]
  set -e argv[1]

  switch "$command"
  case rehash shell
    . (rbenv "sh-$command" $argv|psub)
  case '*'
    command rbenv "$command" $argv
  end
end
~> bash
bash-3.2$ rbenv init -
export PATH="/Users/tambara/.rbenv/shims:${PATH}"
export RBENV_SHELL=bash
source '/usr/local/Cellar/rbenv/1.0.0/libexec/../completions/rbenv.bash'
command rbenv rehash 2>/dev/null
rbenv() {
  local command
  command="$1"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  rehash|shell)
    eval "$(rbenv "sh-$command" "$@")";;
  *)
    command rbenv "$command" "$@";;
  esac
}
bash-3.2$ 

はー。なるほど。というか、rbenvはちゃんとfishに対応してるのね。

http://qiita.com/raccy/items/61bd4780b2bd6de49deb

によれば、

rbenv init - | source

ってすればいいらしい。

自分のPCでプロンプトにユーザー名とホスト名が出ていても嬉しくないので、プロンプトを変える。fish_config と打つとブラウザでプロンプトの変更ができる。Infomativeという長ったらしいやつを選ぶと、その内容が .config/fish/functions/fish_prompt.fish にできるので、ユーザー名とホスト名の部分を推測して出なくした。