訂閱部落格
iterm設定檔
$nano ~/.bash_profile
```
function parse_git_dirty {
if [[ $(git status 2> /dev/null | tail -n1) == "nothing to commit, working directory clean" ]]; then
echo "✔ "
else
echo "✘ "
fi
}
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("$(parse_git_dirty)${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;
last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return;
seconds_since_last_commit=$((now-last_commit));
minutes_since_last_commit=$((seconds_since_last_commit/60));
hours_since_last_commit=$((minutes_since_last_commit/60));
minutes_since_last_commit=$((minutes_since_last_commit%60));
echo "${hours_since_last_commit}h${minutes_since_last_commit}m ";
}
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh
PATH=$HOME/bin:/usr/local/bin:$PATH
PS1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\\[\033[0m\]☀️ "
```
git 設定別名
```
[alias]
co = checkout
ci = commit
st = status
br = branch
amend = commit --amend
```
> Written with [StackEdit](https://stackedit.io/).