0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【GitHub】gitのブランチ名をmacターミナルで表示させる

0
Last updated at Posted at 2021-02-19

gitのブランチ名をmacターミナルで表示させる

$ vim ~/.zshrc
~/.zshrc
# git-promptの読み込み
source /Library/Developer/CommandLineTools/usr/share/git-core/git-prompt.sh

# git-completionの読み込み
fpath=(~/.zsh $fpath)
zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
autoload -Uz compinit && compinit

# プロンプトのオプション表示設定
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUPSTREAM=auto

# プロンプトの表示設定(好きなようにカスタマイズ可)
setopt PROMPT_SUBST ; PS1='%F{green}%n@%m%f: %F{cyan}%~%f %F{red}$(__git_ps1 "(%s)")%f
\$ '
~

ターミナルを開き直して完了!

Macのターミナルのユーザー名の変更

以下を実行

~/.zshrc
export PS1="%1~ %# "

デフォルトに戻す場合

~/.zshrc
export PS1="%n@%m %1~ %# "

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?