顯示具有 bash 標籤的文章。 顯示所有文章
顯示具有 bash 標籤的文章。 顯示所有文章

2017-07-12

Bash on Ubuntu on Windows

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
 
bash
 
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs 


2011-06-11

[git] git cherry-pick 時保有中文訊息

今天在實驗 cherry-pick 時
不意外的發現每個中文訊息都變成亂碼

又在一次的亂槍打鳥隨機搜尋時
發現msysgit 的設定是由 /etc/profile 所控制
然後在檔案最底下發現了這一段代碼
# read user-specific settings, possibly overriding anything above
if [ -e ~/.bashrc ]; then
    . ~/.bashrc
elif [ -e ~/.bash_profile ]; then
    . ~/.bash_profile
elif [ -e /etc/bash_profile ]; then
    . /etc/bash_profile
fi
由以上代碼可知 如果再 windows 使用者資料夾下增加 .bash_profile 這個檔案的話就會被包含進去 msysgit 的環境設定內

 於是我建立了檔案並且內容為
# utf-8 確認可在 cherry-pick 時保有中文訊息
export LESSCHARSET=utf-8
接著又再一次的使用 git cherry-pick 指令
這次就成功的保有中文而沒有變成亂碼了

補充說明以下這三種檔案都可以被認為是 profile 的一部分
但是要注意的是只能有一個起作用
優先順序跟以下的順序相同
  1. ~/.bashrc
  2. ~/.bash_profile
  3. /etc/bash_profile
" ~/ " 代表 WINDOWS的使用者目錄下

2011-06-08

[git] 在 WIN7 MsysGit 環境下安裝 GitFlow

今天在安裝 git-flow 時遇到了點問題
搜尋時第一個就出現 GIT flow on windows 7 with msysgit
一時之間看了 bin.zip 的內容發現只是多了個 getopt

所以就沒多加注意

一開始照著官方的說法在 MSYSGIT 環境下使使用(MSYSGIT的 BASH 介面)
contrib\msysgit-install.cmd
來做安裝但是顯示錯誤

接著就試著使用
make install
來做安裝

看起來是安裝成功了
但是在實際測試
git flow init
時卻又出現一些錯誤訊息
local\bin/gitflow-shFlags: line 1: shFlags/src/shflags: No such file or directory
local\bin/git-flow: line 78: FLAGS: command not found
接下來考慮到可能是安裝時的隱藏錯誤
所以又重新試了一次
contrib\msysgit-install.cmd
這次使用一般的DOS來執行

出現了新的錯誤訊息
MsysGit installation directory not found.
Try to give the directory name on the command line:
  msysgit-install "C:\Program Files\Git"
 由訊息可知無法正確判斷GIT路徑
於是指定了路徑之後 在試一次
但是又出現以下錯誤訊息
bin\getopt.exe not found.
You have to install this file manually. See the GitFlow README.
於是忽然想到在本文開頭提到的 bin.zip 資料夾內有 getopt.exe 這個檔案
於是將 壓縮黨內的檔案都複製到 bin 內
接著又試了一次安裝
contrib\msysgit-install.cmd "D:\msysgit"
這次就沒有錯誤訊息了
於是在重新試了一次 git flow init 也正確執行了