ブシトラの日記

エンジニア1年生の雑多記事

fish 設定

社用PCの設定を自身のPCに移した時のメモ

自分用fish 設定メモ

brew update && brew upgrade && brew cleanup

brew install fish

curl -L https://get.oh-my.fish | fish

omf install https://github.com/jethrokuan/fzf

omf install z

omf install peco

cat ~/.config/fish/config.fish で確認して、なかったら作る(内容は下記)

 

 

source ~/.config/fish/config.fish

デフォルト shellをfish shellに変更
$ sudo vi /etc/shells で、末尾に/usr/local/bin/fishを追加
$ chsh -s /usr/local/bin/fish でデフォルトシェルをfishに変更

内容はこれ

# initialize
function fish_prompt
    if [ $status -eq 0 ]
        set status_face (set_color green)"(*´ω`*) < "
    else
        set status_face (set_color red)"。+゚(∩´﹏'∩)゚+。 < "
    end
    printf '%s %s' (set_color yellow)(prompt_pwd) $status_face
end
# Fish git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
set __fish_git_prompt_showuntrackedfiles 'yes'
set __fish_git_prompt_showupstream 'yes'
set __fish_git_prompt_color_branch yellow
set __fish_git_prompt_color_upstream_ahead green
set __fish_git_prompt_color_upstream_behind red
# Status Chars
set __fish_git_prompt_char_dirtystate '⚡'
set __fish_git_prompt_char_stagedstate '→'
set __fish_git_prompt_char_untrackedfiles '☡'
set __fish_git_prompt_char_stashstate '↩'
set __fish_git_prompt_char_upstream_ahead '+'
set __fish_git_prompt_char_upstream_behind '-'
# right prompt
function fish_right_prompt
  set last_status $status
  printf '%s ' (__fish_git_prompt)
  set_color normal
end
# alias
alias cdd 'cd ~/Desktop'
alias g 'git'
alias ts 'tig status'
function peco_z
    set -l query (commandline)
    if test -n $query
        set peco_flags --query "$query"
    end
    z -l | peco $peco_flags --layout=bottom-up | awk '{ print $2 }' | read recent
    if [ $recent ]
        cd $recent
        commandline -r ''
        commandline -f repaint
    end
end
function peco_ghq
    set -l query (commandline)
    if test -n $query
        set peco_flags --query "$query"
    end
    ghq list --full-path | peco $peco_flags --layout=bottom-up | read recent
    if [ $recent ]
        cd $recent
        commandline -r ''
        commandline -f repaint
    end
end
function fish_user_key_bindings
    bind \cr 'peco_select_history (commandline -b)'
    bind \co peco_ghq
    bind \cq peco_z
end

ctrl r でpeco起動確認、コードミスると"。+゚(∩´﹏'∩)゚+。 < "の顔が出てくる
zsh とか bash とか押せばshell変えられる

fish_config て打つとテーマ変えられる 自分は Solarized Dark が好み

普段はiterm使いだがmghqとtmuxもそのうち試したい