LoginSignup
3
1

More than 3 years have passed since last update.

MAC・iTerm・bashにブランチの状態を表示して使いやすくする

Last updated at Posted at 2018-05-25

- bashに切り替える
$ chsh -s /usr/local/bin/fish

  • Xcodeをインストール
    $ xcode-select --install

  • Homebrewをインストール
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  • wgetをインストール
    $ brew install wget

  • wgetがインストール出来ない場合
    $ xcode-select --install

  • ブランチを表示する為のシェルを取得
    $ cd /usr/local/etc/bash_completion.d/
    $ wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash
    $ wget https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh

  • bashrcを作成し設定(ついでにいくつかエイリアス設定)
    $ cd ~
    $ vim .bashrc

source /usr/local/etc/bash_completion.d/git-prompt.sh
source /usr/local/etc/bash_completion.d/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=true

PS1="\[\033[31m\]\W\[\033[00m\]\[\033[36m\]\$(__git_ps1)\[\033[00m\]\$ "
alias ll='ls -lG'
alias p='python'
alias p3='python3'
alias d='docker'
alias dc='docker-compose'
alias g='git'
alias gdns='git diff --name-status'

#
# git-completion.bash / git-prompt.sh
#
if [ -f /path/git-completion.bash ]; then
    source /path/git-completion.bash
fi
if [ -f /path/git-prompt.sh ]; then
    source /path/git-prompt.sh
fi
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUPSTREAM=auto
  • .bash_profileの設定

$ vim .bash_profile

source ~/.bashrc

下記のエイリアスでさらに開発効率をアップ
よく使うgitコマンドのエイリアスを設定して開発効率をアップする

プロンプトを自由に変えたい場合はこちら
Man page of CONSOLE_CODES
役に立つかもしれないbashプロンプトの3tips

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1