. 讓 command line 指令列顯示目前處在哪乙個 git branch 分支,最早是在 rgba 看到這一招,非常方便。另外我最近看到乙個點子是顯示從上一次 commit 之後過了多久時間,這可以提醒你是不是該 commit 了 xd
請修改家目錄的 ~/.bash_profile 檔案 (我是用 bash)。12
3456
78910
1112
1314
1516
17function git_branch ") ";
}
function git_since_last_commit h$m ";
}
ps1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\$(git_since_last_commit)\[\033[0m\]$ "
view raw
gistfile1.txt hosted with ❤ by
github
結果如下,各位可以看到目前處在 master 分支,並且這個專案已經過了 1821 個小時沒有 commit 了.... :p
2. 安裝 git 的 bash autocompletion,這樣按 tab 就會有自動完成的效果,它甚至包括 git checkout 時都可以抓到你的 branch 名稱。這裡我用 homebrew 來安裝 bash-completion,這套件其實包括很多 autocompletion script,你可以去 /usr/local/etc/bash_completion.d 這個目錄找找看。
brew install bash-completion編輯 ~/.bash_profile 加入cp /usr/local/etc/bash_completion.d/git-completion.bash ~/.git-bash-completion.sh
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh3. 開啟 git 的 color 顏色設定,這樣 git 指令的輸出結果才會加上顏色,像是 git status 等:
git config --global color.ui true4. 設定你偏好的文字編輯器和 diff 工具
git config --global core.editor5. 最後,我個人喜歡以下的 alias:git config --global merge.tool opendiff
git config --global alias.co checkout這樣只要輸入 git st 就是 git status 了。git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
fyi,以上 git 設定檔的位置在 ~/.gitconfig,你也可以直接修改這個檔案。
偏好設定的儲存
1.理解 a.很多ios應用都支援偏好設定,ios提供了一套標準的解決方案來為應用加入偏好設定功能。b.每個應用都有個nsuserdefaults例項,通過它來訪問偏好設定,比如 儲存使用者名稱 字型大小 是否自動登入等。c.注意 userdefaults設定資料時,不是立即寫入,而是根據時間戳定時...
偏好設定儲存
很多ios應用都支援偏好設定,比如儲存使用者名稱 密碼 字型大小等設定,ios提供了一套標準的解決方案來為應用加入偏好設定功能。每個應用都有個nsuserdefaults例項,通過它來訪問偏好設定比如,儲存使用者名稱 字型大小 是否自動登入1 儲存設定資料 nsuserdefaults defaul...
Android偏好設定的使用
沒什麼可講的直接上 這裡只不過是為了自己以後 的復用提高工作效率才寫的文章 sharedpreferences sharedpreferences getsharedpreferences config jump guide mode private sharedpreferences edit p...