---
# System prepended metadata

title: 'Fish shellのインストール・設定【CentOS6, EC2】'
tags: [linux]

---

---
tags: linux
---

# Fish shellのインストール・設定【CentOS6, EC2】

## インストール
```bash
cd /etc/yum.repos.d/
wget http://download.opensuse.org/repositories/shells:fish:release:2/CentOS_6/shells:fish:release:2.repo
yum install -y fish
```  

```bash
chsh -s /usr/bin/fish
```

## Gitプロンプトの変更
```bash
touch ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_showdirtystate \'yes\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_showstashstate \'yes\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_showuntrackedfiles \'yes\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_showupstream \'yes\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_color_branch yellow' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_color_upstream_ahead green' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_color_upstream_behind red' >> ~/.config/fish/config.fish; and \

echo '# Status Chars' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_char_dirtystate \'?\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_char_stagedstate \'→\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_char_untrackedfiles \'?\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_char_stashstate \'?\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_char_upstream_ahead \'+\'' >> ~/.config/fish/config.fish; and \
echo 'set __fish_git_prompt_char_upstream_behind \'-\'' >> ~/.config/fish/config.fish; and \

echo 'set -U fish_user_paths /usr/local/bin $fish_user_paths' >> ~/.config/fish/config.fish
```

```bash
mkdir -p ~/.config/fish/functions/
```

## プロンプトの色や表示を変更

```bash:~/.config/fish/functions/fish_prompt.fish
function fish_prompt
  printf '%s>' (set_color cyan)(prompt_pwd)

  set last_status $status
  printf '%s' (__fish_git_prompt)
  set_color normal
end
```

### 注意点
- don't use `$()`. use `()` instead.
- don't use `$n`, `$@` etc. for arguments, use `$argv`.

```bash
function docker_exec_app
        docker exec -it (docker ps | grep airmobareco | awk '{print $1}') $argv
end
```