Skip to content

Instantly share code, notes, and snippets.

@simics-ja
Last active January 17, 2022 06:05
Show Gist options
  • Save simics-ja/918ac15457f3cc80b7fc9215f051a709 to your computer and use it in GitHub Desktop.
Save simics-ja/918ac15457f3cc80b7fc9215f051a709 to your computer and use it in GitHub Desktop.
[fishとStarshipでおしゃれシェル環境構築] #fish #環境構築

前提

WSL環境であればbrewを入れること

https://brew.sh/

Ubuntuであれば

sudo apt install build-essential procps curl file git
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

fishのセットアップ

brew instaill fish

まずはbrewが使えるようにPATHを通しておく

mkdir -p ~/.config/fish
cat <<'EOF' > ~/.config/fish/config.fish
set -x HOMEBREW_PREFIX /home/linuxbrew/.linuxbrew
set -x HOMEBREW_CELLAR /home/linuxbrew/.linuxbrew/Cellar
set -x HOMEBREW_REPOSITORY /home/linuxbrew/.linuxbrew/Homebrew
set -x PATH /home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin $PATH
set -x MANPATH /home/linuxbrew/.linuxbrew/share/man $MANPATH
set -x INFOPATH /home/linuxbrew/.linuxbrew/share/info $INFOPATH
EOF

fishに切り替えて再起動する

which fish | sudo tee -a /etc/shells
chsh -s /home/linuxbrew/.linuxbrew/bin/fish

Starshipのセットアップ

Starship

StarshipはNERDフォントが必要なのでインストールしてターミナルに設定しておく

フォントはHackGenが良さげ

brew install starship

してからの

echo 'starship init fish | source' >> ~/.config/fish/config.fish

再起動する

見た目をよりカスタマイズしたければドキュメント

NERDfontを探すツールを使うと便利

https://www.nerdfonts.com/cheat-sheet

自分の現状はこんな感じ

# Use custom format
format = """
$username[@](bold black)$hostname$directory$git_branch$git_commit$git_state$git_metrics $git_status $time
[](bold cyan)[ ](bold purple)"""

[username]
disabled = false
format = "[שּ $user]($style)"
show_always = true
style_root = "white bold"
style_user = "white bold"

[hostname]
disabled = false
format = "[$hostname]($style) in "
ssh_only = false
style = "white"
trim_at = "."

[directory]
style = "cyan"

[git_branch]
format = "[$symbol$branch]($style)"

[git_state]
style = "yellow"

[git_status]
ahead = ""
behind = ""
conflicted = "×"
deleted = ""
diverged = ""
format = "[$stashed](cyan)[$conflicted$deleted](red)[$renamed$modified](yellow)[$staged](blue)[$untracked](purple)"
modified = ""
renamed = ""
staged = ""
stashed = ""
untracked = ""
up_to_date = ""

[time]
disabled = false
format = "[ $time]($style)"
style = "bold yellow"

terminal

プラグインを追加する

このままではコマンド履歴をインクリメンタルサーチできなかったりするのでプラグインを追加する

プラグインマネージャにはfisher(https://github.com/jorgebucaran/fisher)を使う

curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
fisher update

fzf

インクリメンタルサーチをできるようにする

https://github.com/jethrokuan/fzf

brew install fzf
fisher install jethrokuan/fzf

fzf-git-recent-branch

ローカルブランチの絞り込み

fisher install tsub/fish-fzf-git-recent-branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment