シェルスクリプトからfishを実行する
あまりユースケースは多くないと思うが、今回あったのはもともとbashが動く前提の環境でfishのをインストールして各種プラグインをセットアップするシェルスクリプトを作りたいケースでこれをやりたかった。
fishがすでに動くfish以外のシェル上から env fish -c "fisher update" みたいな感じで実行できる。
具体的な例。
code:setup_fish.sh
#!/bin/sh
set -ex
echo "=== Install Fish Shell"
if !(type fish) &>/dev/null; then
brew install fish
sudo sh -c "echo '/usr/local/bin/fish' >> /etc/shells"
chsh -s /usr/local/bin/fish
fi
# fisher (fish plugin manager)
echo "=== Install Fisher"
if !(type fisher) &>/dev/null; then
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
fi
env fish -c "fisher update"
参考
https://stackoverflow.com/questions/36594386/using-fish-shell-function-within-a-script
https://fishshell.com/docs/current/cmds/command.html
#fish #memo