2016/05/02

非管理員權限在 macOS 安裝 homebrew


2019/07/08 更新

由於 homebrew 更新了repository 專案名稱

故原 install.rb 會無法安裝

這邊提供我修改後的版本連結: [install.rb](https://gist.github.com/honomoa/08714fb5b517cc83c063a9337a451470)

---

因為沒有那該死的管理員密碼

所以就要想辦法把所有東西都安裝在家目錄下

1. 首先[下載](https://gist.github.com/honomoa/08714fb5b517cc83c063a9337a451470) 別人處理好的安裝腳本存成 install.rb

```
curl https://gist.githubusercontent.com/honomoa/08714fb5b517cc83c063a9337a451470/raw/6e23f7d73a56dc86e7fa46678b9ce0c7ecb00cdc/install.rb -o install.rb
```

2. 修改第1步驟中的 `YOUR_HOME` 變數改成你自己的家目錄

3. 預先建立目錄
```shell
mkdir -p ~/usr/local
```

4. 執行腳本
```ruby
ruby install.rb
```

5. 新增環境變數 ~/.bash_profile
```shell
export HOMEBREW_PREFIX=${HOME}/usr/local
export PATH=${PATH}:${HOMEBREW_PREFIX}/bin
```

6.
```
source ~/.bash_profile
```

這樣你就可以透過 brew 安裝套件了


參考來源:http://superuser.com/questions/619498/can-i-install-homebrew-without-sudo-privileges

2016/04/29

git 如何移除本地端中 remote 已不存在的 branch



常常我們合併了一個 branch 出去之後必須把該 branch 關掉

通常 git server 都可以在網頁上操作關閉該 branch

可是你的 local 並不會自動移除該 remote branch,所以你下 git remote -a 時就會有一堆你曾經 checkout 過的 branch

可以下
```
git remote prune "你要同步的 remote"
```
他就會把 remote 上不存在的分支從你的本地端移除囉

2016/04/27

git 好用的 alias


紀錄一下 git 好用的 alias 以避免公司鎖 evernote 讓我又找不到了

```
[alias]
co = checkout
ci = commit
di = diff --ignore-space-change --ignore-space-at-eol
st = status -sb
br = branch -v
rt = reset --hard
unstage = reset HEAD
uncommit = reset --soft HEAD^
l = log --pretty=oneline --abbrev-commit --graph --decorate
lg = "log --color --graph --oneline --decorate --pretty=format:'%C(auto)%h%Creset%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
amend = commit --amend
who = shortlog -n -s --no-merges
g = grep -n --color -E
cp = cherry-pick -x
nb = checkout -b

# 'git add -u' handles deleted files, but not new files
# 'git add .' handles any current and new files, but not deleted
# 'git addall' now handles all changes
addall = !sh -c 'git add . && git add -u'

# Handy shortcuts for rebasing
rc = rebase --continue
rs = rebase --skip
ra = rebase --abort
ri = rebase --interactive

logf = log --follow
purge = clean -d -f -x
head = !sh -c 'git clean -d -f -x && git reset --hard HEAD'
```

nvm 一套 nodejs 版本管理程式


沒有管理員權限,照樣安裝nodejs

幸好有了 nvm 這玩意,可以把 nodejs 裝在自己目錄下

在安裝 global 套件時也沒問題

** ~~nvm 被系統鎖權限時好用的 nodejs 安裝程式~~ **

**nvm 一套 nodejs 版本管理程式**

非常好

首先我們只要執行 readme 提供的指令就可以了

我的 mac 沒有 wget 所以選擇 curl 安裝

```
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
```

安裝前記得先產生 ~/.bashrc 或是 ~/.bash_profile

不然你的 terminal 不會每次開啟都可以直接設定好喔

結束...

將你 mac 的 terminal 改成 monokai 配色




新工作新 mba 一切都要重新設定,在這邊紀錄一下

我所使用的配色檔是 monokai.terminal

1. 首先 git clone https://github.com/stephenway/monokai.terminal.git

2. 開啟 terminal 並且 import 該描述檔進去就可以了

這樣你的 terminal 就變成美美的

2016/04/26

將你的 vim 改成 monokai 配色




新工作新環境一切都要重新設定,在這邊紀錄一下

我所使用的配色檔是 vim-monokai

1. 首先下載 monokai.vim 並放在 ~/.vim/colors/ 底下

2. 開啟 vim 的 syntax 並設為 monokai

vim 命令模式

# :syntax on 也可以
:syntax enable
:colorscheme monokai


或是編輯 ~/.vimrc

# syntax on 也可以
syntax enable
colorscheme monokai


這樣你的 vim 就變成美美的