LoginSignup
0
0

More than 5 years have passed since last update.

[cocoa][swift]ターミナルでgitの状態を表示する

Posted at

ターミナルでgit操作をしている際に、プロンプトにgitの状態が表示されると便利だ。

Appleが提供する開発環境は、App Store経由で入手できるXcodeをインストールするだけで完了するが、開発者サイトから個別にダウンロードできるCommand Line Tools for Xcodeをインストールしたのちに、以下の対応を行うと、プロンプトにgitの状態が表示される。

.bashrcに以下を記述する。

# Git
 
if [ -f /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash ]; then
    source /Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash
fi
 
if [ -f /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh ]; then
    source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh
fi
 
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUPSTREAM=auto
 
PS1="\h:\W \u\$(__git_ps1)$ "
 
# End Of File

これで完了だ。

【関連情報】
Cocoa Advent Calendar 2018

Cocoa.swift 2019-01

Cocoa.swift

Cocoa勉強会 関東

Cocoa練習帳

Qiita

0
0
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
0
0